Commit 9c4cb797 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Filter out metadata fields that are not requested in zip archiver

Metadata requests in the chrome.fileSystemProvider API declare what
metadata fields they are requesting (i.e. size, modifiction time, etc).
Fields that are provided but not requested will be logged as warnings.

BUG=721790

Change-Id: Ia2c1c1b39f72048be654069557cfc951c5cfc325
Reviewed-on: https://chromium-review.googlesource.com/c/1313989Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604852}
parent 1457da0f
......@@ -284,7 +284,7 @@ unpacker.Volume.prototype.onGetMetadataRequested = function(
if (!entryMetadata)
onError('NOT_FOUND');
else
onSuccess(entryMetadata);
onSuccess(this.filterMetadataEntry_(options, entryMetadata));
};
/**
......@@ -311,7 +311,8 @@ unpacker.Volume.prototype.onReadDirectoryRequested = function(
// Convert dictionary entries to an array.
var entries = [];
for (var entry in directoryMetadata.entries) {
entries.push(directoryMetadata.entries[entry]);
entries.push(
this.filterMetadataEntry_(options, directoryMetadata.entries[entry]));
}
onSuccess(entries, false /* Last call. */);
......@@ -442,3 +443,26 @@ unpacker.Volume.prototype.getEntryMetadata_ = function(entryPath) {
return entryMetadata;
};
/**
* Filters the metadata based on the request options.
* @param {Object} options Options for the metadata request.
* @param {Object} entry Metadata entry to filter.
* @return {Object} The filtered metadata.
* @private
*/
unpacker.Volume.prototype.filterMetadataEntry_ = function(options, entry) {
// Make a copy of the entry so that the original remains unchanged.
var filteredEntry = Object.assign({}, entry);
if (!options.isDirectory)
delete filteredEntry.isDirectory;
if (!options.name)
delete filteredEntry.name;
if (!options.size)
delete filteredEntry.size;
if (!options.modificationTime)
delete filteredEntry.modificationTime;
return filteredEntry;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment