mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Delete un-needed files from mem builds.
This commit is contained in:
parent
0c0da41bb9
commit
be806d293c
13 changed files with 32 additions and 400 deletions
|
@ -6,9 +6,9 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||||
import org.eclipse.jgit.lib.PersonIdent;
|
import org.eclipse.jgit.lib.PersonIdent;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
|
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
|
||||||
|
import uk.ac.ic.wlgitbridge.util.Util;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException;
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -59,7 +59,7 @@ public class WLBridgedProject {
|
||||||
git.commit().setAuthor(new PersonIdent(contents.getUserName(), contents.getUserEmail(), contents.getWhen(), TimeZone.getDefault()))
|
git.commit().setAuthor(new PersonIdent(contents.getUserName(), contents.getUserEmail(), contents.getWhen(), TimeZone.getDefault()))
|
||||||
.setMessage(contents.getCommitMessage())
|
.setMessage(contents.getCommitMessage())
|
||||||
.call();
|
.call();
|
||||||
WLFileStore.deleteInDirectoryApartFrom(contents.getDirectory(), ".git");
|
Util.deleteInDirectoryApartFrom(contents.getDirectory(), ".git");
|
||||||
}
|
}
|
||||||
} catch (InvalidProjectException e) {
|
} catch (InvalidProjectException e) {
|
||||||
throw new RepositoryNotFoundException(name);
|
throw new RepositoryNotFoundException(name);
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.bridge;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.node.WLDirectoryNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 16/11/14.
|
|
||||||
*/
|
|
||||||
public interface bullshit {
|
|
||||||
|
|
||||||
public JsonElement getJsonRepresentation();
|
|
||||||
public int getPreviousVersionID();
|
|
||||||
public String getProjectURL();
|
|
||||||
public void approveWithVersionID(int versionID);
|
|
||||||
public String getProjectName();
|
|
||||||
public WLDirectoryNode getDirectoryNode();
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,11 +3,15 @@ package uk.ac.ic.wlgitbridge.util;
|
||||||
import uk.ac.ic.wlgitbridge.application.SSLConfig;
|
import uk.ac.ic.wlgitbridge.application.SSLConfig;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Winston on 19/11/14.
|
* Created by Winston on 19/11/14.
|
||||||
|
@ -127,4 +131,20 @@ public class Util {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deleteInDirectory(File directory) {
|
||||||
|
deleteInDirectoryApartFrom(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
|
||||||
|
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
|
||||||
|
for (File file : directory.listFiles()) {
|
||||||
|
if (!excluded.contains(file.getName())) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
deleteInDirectory(file);
|
||||||
|
}
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class CandidateSnapshot {
|
||||||
jsonObject.addProperty("latestVerId", currentVersion);
|
jsonObject.addProperty("latestVerId", currentVersion);
|
||||||
jsonObject.add("files", getFilesAsJson(projectURL, postbackKey));
|
jsonObject.add("files", getFilesAsJson(projectURL, postbackKey));
|
||||||
jsonObject.addProperty("postbackUrl", projectURL + "/" + postbackKey + "/postback");
|
jsonObject.addProperty("postbackUrl", projectURL + "/" + postbackKey + "/postback");
|
||||||
|
System.out.println(jsonObject);
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package uk.ac.ic.wlgitbridge.writelatex.filestore;
|
||||||
|
|
||||||
import uk.ac.ic.wlgitbridge.bridge.RawFile;
|
import uk.ac.ic.wlgitbridge.bridge.RawFile;
|
||||||
import uk.ac.ic.wlgitbridge.bridge.WritableRepositoryContents;
|
import uk.ac.ic.wlgitbridge.bridge.WritableRepositoryContents;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
|
import uk.ac.ic.wlgitbridge.util.Util;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -33,7 +33,7 @@ public class GitDirectoryContents implements WritableRepositoryContents {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write() throws IOException {
|
public void write() throws IOException {
|
||||||
WLFileStore.deleteInDirectoryApartFrom(gitDirectory, ".git");
|
Util.deleteInDirectoryApartFrom(gitDirectory, ".git");
|
||||||
for (RawFile fileNode : files) {
|
for (RawFile fileNode : files) {
|
||||||
fileNode.writeToDisk(gitDirectory);
|
fileNode.writeToDisk(gitDirectory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
|
||||||
|
|
||||||
import uk.ac.ic.wlgitbridge.bridge.RawFile;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.RepositoryFile;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 12/11/14.
|
|
||||||
*/
|
|
||||||
public class BlobNode /*extends FileNode*/ {
|
|
||||||
|
|
||||||
// private ByteBlob blob;
|
|
||||||
|
|
||||||
public BlobNode(RawFile rawFile, Map<String, FileNode> context) {
|
|
||||||
// super(rawFile, context);
|
|
||||||
// blob = new RawFileBlob(rawFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlobNode(RepositoryFile repositoryFile, Map<String, FileNode> fileNodeTable, File projectAttDirectory) throws IOException, FailedConnectionException {
|
|
||||||
this(repositoryFile, fileNodeTable);
|
|
||||||
// blob = new RawFileBlob(repositoryFile);
|
|
||||||
writeChanged(projectAttDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlobNode(String fileName, boolean changed, byte[] blob) {
|
|
||||||
// super(fileName, changed);
|
|
||||||
// this.blob = new ByteBlob(blob);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected Blob getBlob() {
|
|
||||||
// return blob;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void updatePersistentStore(PersistentStoreAPI persistentStore, String projectName) {
|
|
||||||
// try {
|
|
||||||
// persistentStore.addFileNodeBlob(projectName, getFilePath(), isChanged(), getBlob().getContents());
|
|
||||||
// } catch (FailedConnectionException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void writeChanged(File projectAttDirectory) throws FailedConnectionException, IOException {
|
|
||||||
// if (isChanged()) {
|
|
||||||
// writeToDisk(projectAttDirectory);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
|
||||||
|
|
||||||
import uk.ac.ic.wlgitbridge.bridge.RawFile;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.model.db.PersistentStoreUpdater;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 12/11/14.
|
|
||||||
*/
|
|
||||||
public abstract class FileNode implements PersistentStoreUpdater<String> {
|
|
||||||
|
|
||||||
private final String filePath;
|
|
||||||
private FileNode previous;
|
|
||||||
private boolean changed;
|
|
||||||
|
|
||||||
public FileNode(RawFile file, Map<String, FileNode> context) {
|
|
||||||
this(file.getPath(), context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileNode(String filePath, Map<String, FileNode> context) {
|
|
||||||
previous = context.get(filePath);
|
|
||||||
this.filePath = filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FileNode(String filePath, boolean changed) {
|
|
||||||
this.filePath = filePath;
|
|
||||||
this.changed = changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FileNode() {
|
|
||||||
filePath = "";
|
|
||||||
previous = null;
|
|
||||||
changed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getContents() throws FailedConnectionException {
|
|
||||||
// return getBlob().getContents();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToDisk(File directory) throws FailedConnectionException, IOException {
|
|
||||||
File file = new File(directory, filePath);
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
file.createNewFile();
|
|
||||||
OutputStream out = new FileOutputStream(file);
|
|
||||||
out.write(getContents());
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilePath() {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChanged() {
|
|
||||||
return changed || previous == null || !equals(previous);
|
|
||||||
}
|
|
||||||
|
|
||||||
// protected abstract Blob getBlob();
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean equals(Object obj) {
|
|
||||||
// if (!(obj instanceof FileNode)) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// FileNode that = (FileNode) obj;
|
|
||||||
// return filePath.equals(that.filePath) && getBlob().equals(that.getBlob());
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
|
||||||
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 08/11/14.
|
|
||||||
*/
|
|
||||||
public class WLDirectoryNode /*implements PersistentStoreSource, PersistentStoreUpdater<Void>*/ {
|
|
||||||
|
|
||||||
// private final String projectName;
|
|
||||||
private Map<String, FileNode> fileNodeTable;
|
|
||||||
|
|
||||||
// public WLDirectoryNode(String projectName, File attsDirectory, File rootGitDirectory, PersistentStoreAPI persistentStore) {
|
|
||||||
// this(projectName, attsDirectory, rootGitDirectory);
|
|
||||||
// initFromPersistentStore(persistentStore);
|
|
||||||
// }
|
|
||||||
|
|
||||||
private WLDirectoryNode(String projectName, File attsDirectory, File rootGitDirectory) {
|
|
||||||
// this.projectName = projectName;
|
|
||||||
new File(attsDirectory, projectName).mkdirs();
|
|
||||||
new File(rootGitDirectory, projectName).mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void initFromPersistentStore(PersistentStoreAPI persistentStore) {
|
|
||||||
// fileIndexStore = new FileIndexStore(projectName, persistentStore);
|
|
||||||
// fileNodeTable = new HashMap<String, FileNode>();
|
|
||||||
// for (FileNode fileNode : persistentStore.getFileNodesForProjectName(projectName, fileIndexStore)) {
|
|
||||||
// fileNodeTable.put(fileNode.getFilePath(), fileNode);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void updatePersistentStore(PersistentStoreAPI persistentStore, Void info) {
|
|
||||||
// updateFileNodeTableInPersistentStore(persistentStore);
|
|
||||||
// fileIndexStore.updatePersistentStore(persistentStore, projectName);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void updateFileNodeTableInPersistentStore(PersistentStoreAPI persistentStore) {
|
|
||||||
// persistentStore.deleteFileNodesForProjectName(projectName);
|
|
||||||
// for (FileNode fileNode : fileNodeTable.values()) {
|
|
||||||
// fileNode.updatePersistentStore(persistentStore, projectName);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public List<FileNode> getFileNodes() {
|
|
||||||
return new LinkedList<FileNode>(fileNodeTable.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FileNode> updateFromSnapshot(Snapshot snapshot) throws FailedConnectionException {
|
|
||||||
Map<String, FileNode> updatedFileNodeTable = new HashMap<String, FileNode>();
|
|
||||||
List<SnapshotFile> srcs = snapshot.getSrcs();
|
|
||||||
List<SnapshotAttachment> atts = snapshot.getAtts();
|
|
||||||
for (SnapshotFile src : srcs) {
|
|
||||||
BlobNode blobNode = new BlobNode(src, fileNodeTable);
|
|
||||||
// updatedFileNodeTable.put(blobNode.getFilePath(), blobNode);
|
|
||||||
}
|
|
||||||
for (SnapshotAttachment att : atts) {
|
|
||||||
// AttachmentNode attachmentNode = new AttachmentNode(att, fileNodeTable, fileIndexStore);
|
|
||||||
// updatedFileNodeTable.put(attachmentNode.getFilePath(), attachmentNode);
|
|
||||||
}
|
|
||||||
LinkedList<FileNode> fileNodes = new LinkedList<FileNode>(updatedFileNodeTable.values());
|
|
||||||
fileNodeTable = updatedFileNodeTable;
|
|
||||||
return fileNodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public WLDirectoryNode createFromRawDirectoryContents(RawDirectoryContents rawDirectoryContents, File attachmentDirectory) throws IOException, FailedConnectionException {
|
|
||||||
// Map<String, FileNode> candidateFileNodeTable = new HashMap<String, FileNode>();
|
|
||||||
// File projectAttDirectory = new File(attachmentDirectory, projectName);
|
|
||||||
// projectAttDirectory.mkdirs();
|
|
||||||
// WLFileStore.deleteInDirectory(projectAttDirectory);
|
|
||||||
// for (Entry<String, byte[]> fileContents : rawDirectoryContents.getFileContentsTable().entrySet()) {
|
|
||||||
// BlobNode blobNode = new BlobNode(new RepositoryFile(fileContents), fileNodeTable, projectAttDirectory);
|
|
||||||
// candidateFileNodeTable.put(blobNode.getFilePath(), blobNode);
|
|
||||||
// }
|
|
||||||
// return new WLDirectoryNode(projectName, candidateFileNodeTable,
|
|
||||||
// new FileIndexStore(new LinkedList<FileNode>(candidateFileNodeTable.values())));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public String toString() {
|
|
||||||
// return fileNodeTable.toString();
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.store;
|
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 08/11/14.
|
|
||||||
*/
|
|
||||||
public class BlobHash {
|
|
||||||
|
|
||||||
private byte[] hash;
|
|
||||||
|
|
||||||
public BlobHash(byte[] blob) {
|
|
||||||
MessageDigest md = null;
|
|
||||||
try {
|
|
||||||
md = MessageDigest.getInstance("SHA-256");
|
|
||||||
hash = md.digest(blob);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
return obj instanceof BlobHash && Arrays.equals(((BlobHash) obj).hash, hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Arrays.hashCode(hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.store;
|
|
||||||
|
|
||||||
import uk.ac.ic.wlgitbridge.bridge.bullshit;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.node.WLDirectoryNode;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 08/11/14.
|
|
||||||
*/
|
|
||||||
public class WLFileStore /*implements PersistentStoreSource*/ {
|
|
||||||
|
|
||||||
private final Map<String, WLDirectoryNode> fileStore;
|
|
||||||
private final File rootGitDirectory;
|
|
||||||
private final File attDirectory;
|
|
||||||
|
|
||||||
// private PersistentStoreAPI persistentStore;
|
|
||||||
|
|
||||||
public WLFileStore(File rootGitDirectory) {
|
|
||||||
fileStore = new HashMap<String, WLDirectoryNode>();
|
|
||||||
this.rootGitDirectory = rootGitDirectory;
|
|
||||||
attDirectory = new File(rootGitDirectory, ".wlgb/atts");
|
|
||||||
attDirectory.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public WLFileStore(File rootGitDirectory, PersistentStoreAPI persistentStoreAPI) {
|
|
||||||
// this(rootGitDirectory);
|
|
||||||
// initFromPersistentStore(persistentStoreAPI);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void initFromPersistentStore(PersistentStoreAPI persistentStore) {
|
|
||||||
// this.persistentStore = persistentStore;
|
|
||||||
// for (String projectName : persistentStore.getProjectNames()) {
|
|
||||||
// fileStore.put(projectName, new WLDirectoryNode(projectName, attDirectory, rootGitDirectory, persistentStore));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static void deleteInDirectory(File directory) {
|
|
||||||
deleteInDirectoryApartFrom(directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
|
|
||||||
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
|
|
||||||
for (File file : directory.listFiles()) {
|
|
||||||
if (!excluded.contains(file.getName())) {
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
deleteInDirectory(file);
|
|
||||||
}
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public List<WritableRepositoryContents> updateForProject(WLProject project) throws FailedConnectionException,
|
|
||||||
// InvalidProjectException {
|
|
||||||
// SortedSet<Snapshot> snapshots = project.fetchNewSnapshots();
|
|
||||||
// String projectName = project.getName();
|
|
||||||
// WLDirectoryNode directoryNode = getDirectoryNodeForProjectName(projectName);
|
|
||||||
// List<WritableRepositoryContents> writableRepositories = new LinkedList<WritableRepositoryContents>();
|
|
||||||
// for (Snapshot snapshot : snapshots) {
|
|
||||||
// writableRepositories.add(new GitDirectoryContents(directoryNode.updateFromSnapshot(snapshot),
|
|
||||||
// rootGitDirectory,
|
|
||||||
// projectName,
|
|
||||||
// snapshot));
|
|
||||||
// }
|
|
||||||
// directoryNode.updatePersistentStore(persistentStore, null);
|
|
||||||
// return writableRepositories;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public WLDirectoryNode createNextDirectoryNodeInProjectFromContents(WLProject project, RawDirectoryContents directoryContents) throws IOException, FailedConnectionException {
|
|
||||||
// return getDirectoryNodeForProjectName(project.getName()).createFromRawDirectoryContents(directoryContents, attDirectory);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void approveCandidateSnapshot(bullshit candidateSnapshot) {
|
|
||||||
WLDirectoryNode directoryNode = candidateSnapshot.getDirectoryNode();
|
|
||||||
fileStore.put(candidateSnapshot.getProjectName(), directoryNode);
|
|
||||||
// directoryNode.updatePersistentStore(persistentStore, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private WLDirectoryNode getDirectoryNodeForProjectName(String projectName) {
|
|
||||||
WLDirectoryNode directoryNode = fileStore.get(projectName);
|
|
||||||
if (directoryNode == null) {
|
|
||||||
// directoryNode = new WLDirectoryNode(projectName, attDirectory, rootGitDirectory, persistentStore);
|
|
||||||
fileStore.put(projectName, directoryNode);
|
|
||||||
}
|
|
||||||
return directoryNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +1,17 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.model;
|
package uk.ac.ic.wlgitbridge.writelatex.model;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import uk.ac.ic.wlgitbridge.bridge.*;
|
import uk.ac.ic.wlgitbridge.bridge.CandidateSnapshotCallback;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.SnapshotFetcher;
|
import uk.ac.ic.wlgitbridge.bridge.RawDirectory;
|
||||||
|
import uk.ac.ic.wlgitbridge.bridge.RawFile;
|
||||||
|
import uk.ac.ic.wlgitbridge.bridge.WritableRepositoryContents;
|
||||||
|
import uk.ac.ic.wlgitbridge.util.Util;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.CandidateSnapshot;
|
import uk.ac.ic.wlgitbridge.writelatex.CandidateSnapshot;
|
||||||
|
import uk.ac.ic.wlgitbridge.writelatex.SnapshotFetcher;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.GitDirectoryContents;
|
import uk.ac.ic.wlgitbridge.writelatex.filestore.GitDirectoryContents;
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
|
|
||||||
import uk.ac.ic.wlgitbridge.writelatex.model.db.PersistentStore;
|
import uk.ac.ic.wlgitbridge.writelatex.model.db.PersistentStore;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -31,7 +34,7 @@ public class DataStore implements CandidateSnapshotCallback {
|
||||||
persistentStore = new PersistentStore(rootGitDirectory);
|
persistentStore = new PersistentStore(rootGitDirectory);
|
||||||
List<String> excludedFromDeletion = persistentStore.getProjectNames();
|
List<String> excludedFromDeletion = persistentStore.getProjectNames();
|
||||||
excludedFromDeletion.add(".wlgb");
|
excludedFromDeletion.add(".wlgb");
|
||||||
WLFileStore.deleteInDirectoryApartFrom(rootGitDirectory, excludedFromDeletion.toArray(new String[] {}));
|
Util.deleteInDirectoryApartFrom(rootGitDirectory, excludedFromDeletion.toArray(new String[]{}));
|
||||||
|
|
||||||
snapshotFetcher = new SnapshotFetcher();
|
snapshotFetcher = new SnapshotFetcher();
|
||||||
resourceFetcher = new ResourceFetcher(persistentStore);
|
resourceFetcher = new ResourceFetcher(persistentStore);
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.model;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 06/11/14.
|
|
||||||
*/
|
|
||||||
public interface JSONModel {
|
|
||||||
|
|
||||||
public void updateFromJSON(JsonElement json);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package uk.ac.ic.wlgitbridge.writelatex.model.db;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Winston on 19/11/14.
|
|
||||||
*/
|
|
||||||
public interface PersistentStoreSource {
|
|
||||||
|
|
||||||
public void initFromPersistentStore(PersistentStore persistentStore);
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue