mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Changed WLDataModel to not delete project directories.
This commit is contained in:
parent
071e0a87cc
commit
7d47514810
4 changed files with 23 additions and 3 deletions
|
@ -9,6 +9,7 @@ import uk.ac.ic.wlgitbridge.writelatex.filestore.GitDirectoryContents;
|
|||
import uk.ac.ic.wlgitbridge.writelatex.filestore.node.WLDirectoryNode;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.WLProject;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.db.PersistentStoreAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -26,11 +27,15 @@ public class WLFileStore {
|
|||
public WLFileStore(File rootGitDirectory) {
|
||||
fileStore = new HashMap<String, WLDirectoryNode>();
|
||||
this.rootGitDirectory = rootGitDirectory;
|
||||
deleteInDirectoryApartFrom(rootGitDirectory, ".wlgb");
|
||||
attDirectory = new File(rootGitDirectory, ".wlgb/atts");
|
||||
attDirectory.mkdirs();
|
||||
}
|
||||
|
||||
public WLFileStore(File rootGitDirectory, PersistentStoreAPI persistentStoreAPI) {
|
||||
this(rootGitDirectory);
|
||||
|
||||
}
|
||||
|
||||
public static void deleteInDirectory(File directory) {
|
||||
deleteInDirectoryApartFrom(directory);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ public class WLDataModel implements CandidateSnapshotCallback {
|
|||
persistentStore = new WLGBPersistentStore(rootGitDirectory);
|
||||
projectStore = persistentStore.loadProjectStore();
|
||||
fileStore = persistentStore.loadFileStore();
|
||||
List<String> excludedFromDeletion = projectStore.getProjectNames();
|
||||
excludedFromDeletion.add(".wlgb");
|
||||
System.out.println("Not deleting: " + excludedFromDeletion);
|
||||
WLFileStore.deleteInDirectoryApartFrom(rootGitDirectory, excludedFromDeletion.toArray(new String[]{}));
|
||||
}
|
||||
|
||||
public List<WritableRepositoryContents> updateProjectWithName(String name) throws FailedConnectionException, InvalidProjectException {
|
||||
|
|
|
@ -3,7 +3,9 @@ package uk.ac.ic.wlgitbridge.writelatex.model;
|
|||
import uk.ac.ic.wlgitbridge.writelatex.model.db.PersistentStoreAPI;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.db.WLDatabaseSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -17,6 +19,11 @@ public class WLProjectStore implements WLDatabaseSource {
|
|||
projects = new HashMap<String, WLProject>();
|
||||
}
|
||||
|
||||
public WLProjectStore(PersistentStoreAPI persistentStore) {
|
||||
this();
|
||||
initFromDatabase(persistentStore);
|
||||
}
|
||||
|
||||
public WLProject getProjectWithName(String name) {
|
||||
WLProject project;
|
||||
if (projects.containsKey(name)) {
|
||||
|
@ -28,6 +35,10 @@ public class WLProjectStore implements WLDatabaseSource {
|
|||
return project;
|
||||
}
|
||||
|
||||
public List<String> getProjectNames() {
|
||||
return new ArrayList<String>(projects.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFromDatabase(PersistentStoreAPI database) {
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ public class WLGBPersistentStore implements PersistentStoreAPI {
|
|||
|
||||
@Override
|
||||
public WLProjectStore loadProjectStore() {
|
||||
return new WLProjectStore();
|
||||
return new WLProjectStore(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WLFileStore loadFileStore() {
|
||||
return new WLFileStore(rootGitDirectory);
|
||||
return new WLFileStore(rootGitDirectory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue