diff --git a/js/file-manager.js b/js/file-manager.js index f2b5054d..38f44904 100644 --- a/js/file-manager.js +++ b/js/file-manager.js @@ -295,11 +295,7 @@ define(["jquery", "core", "gdrive", "synchronizer", "async-runner"], function($, if(fileId.length === 0) { return; } - gdrive.downloadMetadata([fileId], function(result) { - if(result === undefined || result.length === 0) { - return; - } - }); + gdrive.importFiles([fileId]); } function refreshManageSync() { diff --git a/js/gdrive.js b/js/gdrive.js index 5539cc69..d52a4129 100644 --- a/js/gdrive.js +++ b/js/gdrive.js @@ -254,8 +254,8 @@ define(["jquery", "core", "async-runner"], function($, core, asyncTaskRunner) { message: jqXHR.statusText }; // Handle error - if(error.code === 403) { - error = "File is not available"; + if(error.code === 403 || error.code === 404) { + error = "File is not available."; } handleError(error, asyncTask, callback); }); @@ -365,6 +365,27 @@ define(["jquery", "core", "async-runner"], function($, core, asyncTaskRunner) { gdrive.updateFile = function(id, title, content, callback) { upload(id, undefined, title, content, callback); }; + + gdrive.importFiles = function(ids) { + gdrive.downloadMetadata(ids, function(result) { + if(result === undefined) { + return; + } + gdrive.downloadContent(result, function(result) { + if(result === undefined) { + return; + } + for(var i=0; i