Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: ui/file_manager/file_manager/background/js/duplicate_finder.js

Issue 881463003: Files.app: Add a deduplication step to avoid importing duplicate media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to master; fix Banners test. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/background/js/duplicate_finder.js
diff --git a/ui/file_manager/file_manager/background/js/duplicate_finder.js b/ui/file_manager/file_manager/background/js/duplicate_finder.js
new file mode 100644
index 0000000000000000000000000000000000000000..70439cdd9e52efce49c60f17cf7af214a061473b
--- /dev/null
+++ b/ui/file_manager/file_manager/background/js/duplicate_finder.js
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Namespace
+var importer = importer || {};
+
+/**
+ * Interface for import deduplicators. A duplicate finder is linked to an
+ * import destination, and will check whether files already exist in that import
+ * destination.
+ * @interface
+ */
+importer.DuplicateFinder = function() {};
+
+/**
+ * Checks whether the given file already exists in the import destination.
+ * @param {!FileEntry} entry The file entry to check.
+ * @return {!Promise<boolean>}
+ */
+importer.DuplicateFinder.prototype.checkDuplicate;
+
+/**
+ * A duplicate finder for Google Drive.
+ * @constructor
+ * @implements {importer.DuplicateFinder}
+ * @struct
+ */
+importer.DriveDuplicateFinder = function() {};
+
+/** @override */
+importer.DriveDuplicateFinder.prototype.checkDuplicate = function(entry) {
+ // TODO(kenobi): Implement content hash deduplication.
+ return Promise.resolve(false);
+};
+
+/**
+ * A duplicate finder for testing. Allows the return value to be set.
+ * @constructor
+ * @implements {importer.DuplicateFinder}
+ * @struct
+ */
+importer.TestDuplicateFinder = function() {
+ /** @type {boolean} */
+ this.returnValue = false;
+};
+
+/** @override */
+importer.TestDuplicateFinder.prototype.checkDuplicate = function(entry) {
+ return Promise.resolve(this.returnValue);
+};

Powered by Google App Engine
This is Rietveld 408576698