From: Pawel Andruszkiewicz Date: Wed, 29 Jul 2015 07:17:19 +0000 (+0200) Subject: [Filesystem] Resolving a path on an unmounted storage should result in NotFound error. X-Git-Tag: submit/tizen_tv/20150803.021740^2^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3ba112bdf77c350ddb1e2d011b9e33a971b4f38;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Filesystem] Resolving a path on an unmounted storage should result in NotFound error. Fixes: UTC_filesystem_check_sdcard_resolve [Verification] Wearable service UTC: 90/94 Mobile TCT: 289/289 Change-Id: Idd1ed6b2ad624057d22a52e50671316161334512 Signed-off-by: Pawel Andruszkiewicz --- diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js index cae012c3..ed45ada6 100755 --- a/src/filesystem/js/common.js +++ b/src/filesystem/js/common.js @@ -117,9 +117,7 @@ var commonFS_ = (function() { var _pathTokens = aPath.split('/'); - if (cacheVirtualToReal[_pathTokens[0]] && ( - cacheVirtualToReal[_pathTokens[0]].state === undefined || - cacheVirtualToReal[_pathTokens[0]].state === FileSystemStorageState.MOUNTED)) { + if (cacheVirtualToReal[_pathTokens[0]]) { _fileRealPath = cacheVirtualToReal[_pathTokens[0]].path; for (var i = 1; i < _pathTokens.length; ++i) { _fileRealPath += '/' + _pathTokens[i]; @@ -129,9 +127,7 @@ var commonFS_ = (function() { _fileRealPath = undefined; // check storages for (var j = 0; j < cacheStorages.length; ++j) { - if (cacheStorages[j].label === _pathTokens[0] && ( - cacheStorages[j].state === undefined || - cacheStorages[j].state === FileSystemStorageState.MOUNTED)) { + if (cacheStorages[j].label === _pathTokens[0]) { _fileRealPath = cacheStorages[j].path; for (var i = 1; i < _pathTokens.length; ++i) { _fileRealPath += '/' + _pathTokens[i]; diff --git a/src/filesystem/js/file_system_manager.js b/src/filesystem/js/file_system_manager.js index 8bff86e8..836a4ccb 100755 --- a/src/filesystem/js/file_system_manager.js +++ b/src/filesystem/js/file_system_manager.js @@ -52,6 +52,18 @@ FileSystemManager.prototype.resolve = function(location, onsuccess, onerror, mod }, 0); return; } + + // resolving a path on unmounted storage should result in exception + var storage = commonFS_.getStorage(args.location.split('/')[0]); + if (storage && FileSystemStorageState.MOUNTED !== storage.state) { + setTimeout(function() { + native_.callIfPossible(args.onerror, + new WebAPIException(WebAPIException.NOT_FOUND_ERR, + 'Storage is not mounted.')); + }, 0); + return; + } + var _realPath = commonFS_.toRealPath(args.location); var _isLocationAllowed = commonFS_.isLocationAllowed(_realPath);