Added loading of AttachmentNode blobs.

This commit is contained in:
Winston Li 2014-12-04 17:41:37 +00:00
parent f429c4bf8b
commit 1db7670f05
4 changed files with 13 additions and 6 deletions

View file

@ -27,9 +27,14 @@ public class AttachmentNode extends FileNode {
initBlob(fileIndexes);
}
public AttachmentNode(String filePath, boolean changed, String url) {
public AttachmentNode(String filePath, boolean changed, String url, FileIndexStore fileIndexStore) {
super(filePath, changed);
this.url = url;
try {
initBlob(fileIndexStore);
} catch (FailedConnectionException e) {
throw new RuntimeException(e);
}
}
public AttachmentNode(String url, byte[] blob) {

View file

@ -46,11 +46,11 @@ public class WLDirectoryNode implements PersistentStoreSource, PersistentStoreUp
@Override
public void initFromPersistentStore(PersistentStoreAPI persistentStore) {
fileIndexStore = new FileIndexStore(projectName, persistentStore);
fileNodeTable = new HashMap<String, FileNode>();
for (FileNode fileNode : persistentStore.getFileNodesForProjectName(projectName)) {
for (FileNode fileNode : persistentStore.getFileNodesForProjectName(projectName, fileIndexStore)) {
fileNodeTable.put(fileNode.getFilePath(), fileNode);
}
fileIndexStore = new FileIndexStore(projectName, persistentStore);
}
@Override

View file

@ -1,6 +1,7 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db;
import uk.ac.ic.wlgitbridge.writelatex.filestore.node.FileNode;
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.FileIndexStore;
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
import uk.ac.ic.wlgitbridge.writelatex.model.WLProjectStore;
@ -23,7 +24,7 @@ public interface PersistentStoreAPI {
public List<String> getProjectNames();
public List<Integer> getVersionIDsForProjectName(String projectName);
public List<FileNode> getFileNodesForProjectName(String projectName);
public List<FileNode> getFileNodesForProjectName(String projectName, FileIndexStore fileIndexStore);
public Map<String, FileNode> getURLIndexTableForProjectName(String projectName);
public void deleteFileNodesForProjectName(String projectName);

View file

@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge.writelatex.model.db;
import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.filestore.node.FileNode;
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.FileIndexStore;
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
import uk.ac.ic.wlgitbridge.writelatex.model.WLProjectStore;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLiteWLDatabase;
@ -104,9 +105,9 @@ public class WLGBPersistentStore implements PersistentStoreAPI {
}
@Override
public List<FileNode> getFileNodesForProjectName(String projectName) {
public List<FileNode> getFileNodesForProjectName(String projectName, FileIndexStore fileIndexStore) {
try {
return database.getFileNodesForProjectName(projectName);
return database.getFileNodesForProjectName(projectName, fileIndexStore);
} catch (SQLException e) {
throw new RuntimeException(e);
}