From: Piotr Kosko Date: Tue, 30 Dec 2014 11:08:19 +0000 (+0100) Subject: [Archive] Fixes for TCTs X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~705^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ad1168777762be6b7f6394c756ab1ee5669ee0e;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Archive] Fixes for TCTs [Verification] TCT passrate 97/105 Change-Id: I27053813629c2a32d31977615cc55cd041559322 Signed-off-by: Piotr Kosko --- diff --git a/src/archive/archive_api.js b/src/archive/archive_api.js index 3dd13170..80931e64 100644 --- a/src/archive/archive_api.js +++ b/src/archive/archive_api.js @@ -72,6 +72,12 @@ CommonFS.toRealPath = function(aPath) { return _fileRealPath; }; +CommonFS.isVirtualPath = function(aPath) { + var root = aPath.split("/")[0]; + + return this.cacheVirtualToReal[root] != undefined; +}; + /** * Returns new unique opId */ @@ -173,6 +179,9 @@ ArchiveFileEntry.prototype.extract = function () { ]), opId = getNextOpId(); + if (!CommonFS.isVirtualPath(args.destinationDirectory)) //TODO: add FileReferece validation + throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + "Destination directory should be virtual path or file."); bridge.async({ cmd: 'ArchiveFileEntry_extract', args: { @@ -248,6 +257,10 @@ ArchiveFile.prototype.add = function () { ]), opId = getNextOpId(); + if (!CommonFS.isVirtualPath(args.sourceFile)) //TODO: add FileReferece validation + throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + "sourceFile should be virtual path or file."); + var optionsAttributes = ["destination", "stripSourceDirectory", "compressionLevel"], options = args.options || {}; @@ -307,6 +320,10 @@ ArchiveFile.prototype.extractAll = function () { ]), opId = getNextOpId(); + if (!CommonFS.isVirtualPath(args.destinationDirectory)) //TODO: add FileReferece validation + throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + "destinationDirectory should be virtual path or file."); + bridge.async({ cmd: 'ArchiveFile_extractAll', args: { @@ -453,6 +470,10 @@ ArchiveManager.prototype.open = function () { } } + if (!CommonFS.isVirtualPath(args.file)) //TODO: add FileReferece validation + throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, + "file should be virtual path or file."); + bridge.async({ cmd: 'ArchiveManager_open', args: { diff --git a/src/archive/archive_instance.cc b/src/archive/archive_instance.cc index c8cc7f4e..a7bf62ca 100644 --- a/src/archive/archive_instance.cc +++ b/src/archive/archive_instance.cc @@ -394,10 +394,13 @@ void ArchiveInstance::Close(const picojson::value& args, picojson::object& out) const long handle = static_cast(v_handle.get()); - ArchiveFilePtr priv = ArchiveManager::getInstance().getPrivData(handle); - priv->close(); - ArchiveManager::getInstance().erasePrivData(handle); - + try { + ArchiveFilePtr priv = ArchiveManager::getInstance().getPrivData(handle); + priv->close(); + ArchiveManager::getInstance().erasePrivData(handle); + } catch (...) { + LoggerD("Close method was called on already closed archive. Just end execution"); + } ReportSuccess(out); }