From: Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics Date: Fri, 20 Aug 2021 11:50:33 +0000 (+0200) Subject: [Common] Added caching custom virutal paths X-Git-Tag: submit/tizen/20210820.124425^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e05f77ec27b3315f29267ea446d31f85fb02a99a;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Common] Added caching custom virutal paths 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 --- diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js index d3c17cd3..ac876934 100644 --- a/src/filesystem/js/common.js +++ b/src/filesystem/js/common.js @@ -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) {