Chromium Code Reviews| Index: ui/file_manager/file_manager/common/js/importer_common.js |
| diff --git a/ui/file_manager/file_manager/common/js/importer_common.js b/ui/file_manager/file_manager/common/js/importer_common.js |
| index c38bdbad8aa476b820ba927bc8836cd43dd8cc48..cbcf88600534cb5118676a64be7e5945f458d207 100644 |
| --- a/ui/file_manager/file_manager/common/js/importer_common.js |
| +++ b/ui/file_manager/file_manager/common/js/importer_common.js |
| @@ -367,6 +367,43 @@ importer.PromisingFileEntry.prototype.getMetadata = function() { |
| }; |
| /** |
| + * This prefix is stripped from URL used in import history. It is stripped |
| + * to same on disk space, parsing time, and runtime memory. |
| + * @private @const {string} |
| + */ |
| +importer.APP_URL_PREFIX_ = |
| + 'filesystem:chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/external'; |
| + |
| +/** |
| + * Strips non-unique information from the URL. The resulting |
| + * value can be reconstituted using {@code importer.inflateAppUrl}. |
| + * |
| + * @param {string} url |
| + * @return {string} |
| + */ |
| +importer.deflateAppUrl = function(url) { |
| + if (url.substring(0, importer.APP_URL_PREFIX_.length) === |
| + importer.APP_URL_PREFIX_) { |
| + return '$' + url.substring(importer.APP_URL_PREFIX_.length); |
| + } |
| + |
| + return url; |
| +}; |
| + |
| +/** |
| + * Reconstitutes a url previous deflated by {@code deflateAppUrl}. |
|
mtomasz
2015/02/25 00:40:17
nit: Can you add a comment what it returns if it w
Steve McKay
2015/02/25 01:51:56
Done.
|
| + * |
| + * @param {string} deflated |
| + * @return {string} |
| + */ |
| +importer.inflateAppUrl = function(deflated) { |
| + if (deflated.substring(0, 1) === '$') { |
| + return importer.APP_URL_PREFIX_ + deflated.substring(1); |
| + } |
| + return deflated; |
| +}; |
| + |
| +/** |
| * @param {!FileEntry} fileEntry |
| * @return {!Promise.<string>} Resolves with a "hashcode" consisting of |
| * just the last modified time and the file size. |
| @@ -393,10 +430,26 @@ importer.createMetadataHashcode = function(fileEntry) { |
| } else if (!('size' in metadata)) { |
| reject('File entry missing "size" field.'); |
| } else { |
| - resolve(metadata.modificationTime + '_' + metadata.size); |
| + var secondsSinceEpoch = |
| + importer.toSecondsFromEpoch(metadata.modificationTime); |
| + resolve(secondsSinceEpoch + '_' + metadata.size); |
| } |
| }.bind(this)); |
| - }.bind(this)); |
| + }.bind(this)) |
| + .catch(importer.getLogger().catcher('importer-common-create-hashcode')); |
| +}; |
| + |
| +/** |
| + * @param {string} date A date string in the form |
| + * expected by Date.parse. |
| + * @return {string} The number of seconds from epoch to the date...as a string. |
| + */ |
| +importer.toSecondsFromEpoch = function(date) { |
| + // Since we're parsing a value that only has |
| + // precision to the second, our last three digits |
| + // will always be 000. We strip them and end up |
| + // with seconds. |
| + return String(Date.parse(date)).substring(0, 10); |
|
mtomasz
2015/02/25 00:40:17
nit: This will not work as intended for pictures c
Steve McKay
2015/02/25 01:51:56
Oh, really good catch. Fixed.
|
| }; |
| /** |
| @@ -589,8 +642,8 @@ importer.ChromeSyncFileEntryProvider.prototype.handleSyncEvent_ = |
| } |
| if (event.action && event.action !== 'updated') { |
| - console.error( |
| - 'Unexpected sync event action for sync file: ' + event.action); |
| + console.warn( |
| + 'Unusual sync event action for sync file: ' + event.action); |
| return; |
| } |