1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-04-11 12:34:04 +00:00

Delete project atts directory after push.

This commit is contained in:
Winston Li 2015-02-22 10:09:35 +00:00
parent 59001735b1
commit ec0c70c622
2 changed files with 14 additions and 3 deletions
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/writelatex

View file

@ -23,6 +23,7 @@ public class CandidateSnapshot {
private final int currentVersion;
private final List<ServletFile> files;
private final List<String> deleted;
private File attsDirectory;
public CandidateSnapshot(String projectName, int currentVersion, RawDirectory directoryContents, RawDirectory oldDirectoryContents) {
this.projectName = projectName;
@ -56,14 +57,20 @@ public class CandidateSnapshot {
}
public void writeServletFiles(File rootGitDirectory) throws IOException {
File directory = new File(rootGitDirectory, ".wlgb/atts/" + projectName);
attsDirectory = new File(rootGitDirectory, ".wlgb/atts/" + projectName);
for (ServletFile file : files) {
if (file.isChanged()) {
file.writeToDisk(directory);
file.writeToDisk(attsDirectory);
}
}
}
public void deleteServletFiles() throws IOException {
if (attsDirectory != null) {
Util.deleteInDirectory(attsDirectory);
}
}
public JsonElement getJsonRepresentation(String postbackKey) {
String projectURL = Util.getPostbackURL() + projectName;
JsonObject jsonObject = new JsonObject();

View file

@ -71,10 +71,11 @@ public class WriteLatexAPI implements WriteLatexDataSource {
@Override
public void putDirectoryContentsToProjectWithName(String projectName, RawDirectory directoryContents, RawDirectory oldDirectoryContents, String hostname) throws SnapshotPostException, IOException {
mainProjectLock.lockForProject(projectName);
CandidateSnapshot candidate = null;
try {
Util.sout("Pushing project: " + projectName);
String postbackKey = postbackManager.makeKeyForProject(projectName);
CandidateSnapshot candidate = dataModel.createCandidateSnapshotFromProjectWithContents(projectName, directoryContents, oldDirectoryContents);
candidate = dataModel.createCandidateSnapshotFromProjectWithContents(projectName, directoryContents, oldDirectoryContents);
SnapshotPushRequest snapshotPushRequest = new SnapshotPushRequest(candidate, postbackKey);
snapshotPushRequest.request();
SnapshotPushRequestResult result = snapshotPushRequest.getResult();
@ -91,6 +92,9 @@ public class WriteLatexAPI implements WriteLatexDataSource {
} catch (IOException e) {
throw e;
} finally {
if (candidate != null) {
candidate.deleteServletFiles();
}
mainProjectLock.unlockForProject(projectName);
}
}