[Common] Added caching custom virutal paths 54/262854/1
authorPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Fri, 20 Aug 2021 11:50:33 +0000 (13:50 +0200)
committerPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Fri, 20 Aug 2021 11:50:36 +0000 (13:50 +0200)
This change is related to:
https://review.tizen.org/gerrit/#/c/platform/core/api/webapi-plugins/+/260943/

As in some scenarios (when new storage is mounted) webapi clears cache,
there is a need to restore custom virtual paths which are set with
setVirtualPath() method.

[Verification] Code compiles without errors.

Change-Id: I9dde4025526936e8988ff610f70894d4dbb00e60

src/filesystem/js/common.js

index d3c17cd..ac87693 100644 (file)
@@ -48,6 +48,7 @@ var commonFS_ = (function() {
     var cacheReady = false;
     var listenerRegistered = false;
     var cacheVirtualToReal = {};
+    var userVirtual = {};
     var cacheStorages = [];
     var uriPrefix = 'file://';
     // special condition for previous versions paths
@@ -104,6 +105,10 @@ var commonFS_ = (function() {
         // (global paths usage issue workaround)
         initHomeDir();
 
+        for (var name in userVirtual) {
+            cacheVirtualToReal[name] = userVirtual[name];
+        }
+
         var result = native_.callSync('FileSystemManagerFetchStorages', {});
         if (native_.isFailure(result)) {
             throw native_.getErrorObject(result);
@@ -141,6 +146,7 @@ var commonFS_ = (function() {
     function setVirtualPath(name, path, type, state) {
         initCache();
         cacheVirtualToReal[name] = { path: path, label: name, type: type, state: state };
+        userVirtual[name] = { path: path, label: name, type: type, state: state };
     }
 
     function mergeMultipleSlashes(str) {