From 1ad1168777762be6b7f6394c756ab1ee5669ee0e Mon Sep 17 00:00:00 2001
From: Piotr Kosko
Date: Tue, 30 Dec 2014 12:08:19 +0100
Subject: [PATCH] [Archive] Fixes for TCTs
[Verification] TCT passrate 97/105
Change-Id: I27053813629c2a32d31977615cc55cd041559322
Signed-off-by: Piotr Kosko
---
src/archive/archive_api.js | 21 +++++++++++++++++++++
src/archive/archive_instance.cc | 11 +++++++----
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/src/archive/archive_api.js b/src/archive/archive_api.js
index 3dd1317..80931e6 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 c8cc7f4..a7bf62c 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);
}
--
2.7.4