mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Now deleting all files before writing snapshot to disk.
This commit is contained in:
parent
1e8d7d5840
commit
3bbef6f066
2 changed files with 13 additions and 0 deletions
|
@ -3,6 +3,7 @@ package uk.ac.ic.wlgitbridge.writelatex.filestore;
|
|||
import uk.ac.ic.wlgitbridge.bridge.WritableRepositoryContents;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.node.FileNode;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -30,6 +31,7 @@ public class GitDirectoryContents implements WritableRepositoryContents {
|
|||
|
||||
@Override
|
||||
public void write() throws IOException, FailedConnectionException {
|
||||
WLFileStore.deleteInDirectoryApartFrom(gitDirectory, ".git");
|
||||
for (FileNode fileNode : fileNodes) {
|
||||
fileNode.writeToDisk(gitDirectory);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,17 @@ public class WLFileStore {
|
|||
}
|
||||
}
|
||||
|
||||
public static void deleteInDirectoryApartFrom(File directory, String apartFrom) {
|
||||
for (File file : directory.listFiles()) {
|
||||
if (!file.getName().equals(apartFrom)) {
|
||||
if (file.isDirectory()) {
|
||||
deleteInDirectory(file);
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<WritableRepositoryContents> updateForProject(WLProject project) throws FailedConnectionException,
|
||||
InvalidProjectException {
|
||||
SortedSet<Snapshot> snapshots = project.fetchNewSnapshots();
|
||||
|
|
Loading…
Reference in a new issue