Просмотр исходного кода

Added fix for testing equality of ByteBlobs

Winston Li 12 лет назад
Родитель
Сommit
794a0e29e6

+ 11 - 0
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/blob/ByteBlob.java

@@ -3,6 +3,8 @@ package uk.ac.ic.wlgitbridge.writelatex.filestore.blob;
 import uk.ac.ic.wlgitbridge.writelatex.filestore.node.AttachmentNode;
 import uk.ac.ic.wlgitbridge.writelatex.model.db.PersistentStoreAPI;
 
+import java.util.Arrays;
+
 /**
  * Created by Winston on 14/11/14.
  */
@@ -19,6 +21,15 @@ public class ByteBlob extends Blob {
         return contents;
     }
 
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof ByteBlob)) {
+            return false;
+        }
+        ByteBlob that = (ByteBlob) obj;
+        return Arrays.equals(contents, that.contents);
+    }
+
     @Override
     public void updatePersistentStore(PersistentStoreAPI persistentStore, AttachmentNode node) {
         persistentStore.addFileNodeBlob(node.getProjectName(), node.getFilePath(), node.isChanged(), contents);

+ 9 - 0
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/node/BlobNode.java

@@ -34,6 +34,15 @@ public class BlobNode extends FileNode {
         this.blob = new ByteBlob(blob);
     }
 
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof BlobNode)) {
+            return false;
+        }
+        BlobNode that = (BlobNode) obj;
+        return super.equals(that) && blob.equals(that.blob);
+    }
+
     @Override
     public void indexWith(FileNodeIndexer fileNodeIndexer) {
         fileNodeIndexer.index(this);

+ 0 - 1
services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/node/WLDirectoryNode.java

@@ -92,7 +92,6 @@ public class WLDirectoryNode implements PersistentStoreSource, PersistentStoreUp
 
     public WLDirectoryNode createFromRawDirectoryContents(RawDirectoryContents rawDirectoryContents, File attachmentDirectory) throws IOException, FailedConnectionException {
         Map<String, FileNode> candidateFileNodeTable = new HashMap<String, FileNode>();
-        System.out.println("Attachment directory: " + attachmentDirectory + ", projectName: " + projectName);
         File projectAttDirectory = new File(attachmentDirectory, projectName);
         projectAttDirectory.mkdirs();
         WLFileStore.deleteInDirectory(projectAttDirectory);