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

Unified Diff: ui/file_manager/zip_archiver/js/compressor.js

Issue 2807063002: Replace Libarchive with MiniZip. (Closed)
Patch Set: Fix a few nits. Created 3 years, 8 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
« no previous file with comments | « ui/file_manager/zip_archiver/js/background.js ('k') | ui/file_manager/zip_archiver/js/passphrase-dialog.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/zip_archiver/js/compressor.js
diff --git a/ui/file_manager/zip_archiver/js/compressor.js b/ui/file_manager/zip_archiver/js/compressor.js
index a96fd4db7375d809bcc81623df9cee62b5df2c68..a48f514deab37a4b27873f3adcb43d802559b392 100644
--- a/ui/file_manager/zip_archiver/js/compressor.js
+++ b/ui/file_manager/zip_archiver/js/compressor.js
@@ -289,15 +289,13 @@ unpacker.Compressor.prototype.sendAddToArchiveRequest_ = function() {
if (fullPath.length && fullPath[0] == '/')
fullPath = fullPath.substring(1);
- // Modification time is sent as string in a format: 'mm/dd/yy hh:mm:ss'.
- var mt = this.metadata_[entryId].modificationTime;
- var formattedTime = (mt.getMonth() + 1) + '/' + mt.getDate() + '/' +
- mt.getFullYear() + ' ' + mt.getHours() + ':' +
- mt.getMinutes() + ':' + mt.getSeconds();
+ // Modification time is set to the archive in local time.
+ var utc = this.metadata_[entryId].modificationTime;
+ var modificationTime = utc.getTime() - (utc.getTimezoneOffset() * 60000);
var request = unpacker.request.createAddToArchiveRequest(
this.compressorId_, entryId, fullPath,
- this.metadata_[entryId].size, formattedTime,
+ this.metadata_[entryId].size, modificationTime,
this.entries_[entryId].isDirectory);
this.naclModule_.postMessage(request);
}
@@ -395,13 +393,15 @@ unpacker.Compressor.prototype.onReadFileChunk_ = function(data) {
* @private
*/
unpacker.Compressor.prototype.onWriteChunk_ = function(data) {
+ var offset = Number(data[unpacker.request.Key.OFFSET]);
var length = Number(data[unpacker.request.Key.LENGTH]);
var buffer = data[unpacker.request.Key.CHUNK_BUFFER];
- this.writeChunk_(length, buffer, this.sendWriteChunkDone_.bind(this));
+ this.writeChunk_(offset, length, buffer, this.sendWriteChunkDone_.bind(this));
}
/**
* Writes buffer into the archive file (window.archiveFileEntry).
+ * @param {number} offset The offset from which date is written.
* @param {number} length The number of bytes in the buffer to write.
* @param {!ArrayBuffer} buffer The buffer to write in the archive.
* @param {function(number)} callback Callback to execute at the end of the
@@ -410,7 +410,7 @@ unpacker.Compressor.prototype.onWriteChunk_ = function(data) {
* a negative value must be assigned to this argument.
* @private
*/
-unpacker.Compressor.prototype.writeChunk_ = function(length, buffer,
+unpacker.Compressor.prototype.writeChunk_ = function(offset, length, buffer,
callback) {
// TODO(takise): Use the same instance of FileWriter over multiple calls of
// this function instead of creating new ones.
@@ -430,7 +430,7 @@ unpacker.Compressor.prototype.writeChunk_ = function(length, buffer,
// Create a new Blob and append it to the archive file.
var blob = new Blob([buffer], {});
- fileWriter.seek(fileWriter.length);
+ fileWriter.seek(offset);
fileWriter.write(blob);
}, function(event) {
console.error('Failed to create writer for ' + this.archiveFileEntry_ +
« no previous file with comments | « ui/file_manager/zip_archiver/js/background.js ('k') | ui/file_manager/zip_archiver/js/passphrase-dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698