[Filesystem] Resolving a path on an unmounted storage should result in NotFound error.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 29 Jul 2015 07:17:19 +0000 (09:17 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 29 Jul 2015 07:17:19 +0000 (09:17 +0200)
Fixes: UTC_filesystem_check_sdcard_resolve
[Verification] Wearable service UTC: 90/94
               Mobile TCT: 289/289

Change-Id: Idd1ed6b2ad624057d22a52e50671316161334512
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/filesystem/js/common.js
src/filesystem/js/file_system_manager.js

index cae012c32efa125fdce377cdb31d142ca7429aa0..ed45ada63c0ce502f71ac65dcdbd04daaa6562b4 100755 (executable)
@@ -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];
index 8bff86e8f42655711a9c3f5c70d1d0240ae2e602..836a4ccb9971519d93538b4aa01c8d2efad6e241 100755 (executable)
@@ -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);