Browse Source

enhance: instrument if path doesn't include `///`

Tienson Qin 3 years ago
parent
commit
089c503c1f
1 changed files with 14 additions and 3 deletions
  1. 14 3
      src/main/frontend/fs/capacitor_fs.cljs

+ 14 - 3
src/main/frontend/fs/capacitor_fs.cljs

@@ -12,7 +12,8 @@
             [frontend.util :as util]
             [lambdaisland.glogi :as log]
             [promesa.core :as p]
-            [rum.core :as rum]))
+            [rum.core :as rum]
+            [logseq.graph-parser.util :as gp-util]))
 
 (when (mobile-util/native-ios?)
   (defn ios-ensure-documents!
@@ -215,10 +216,20 @@
 (defn ios-force-include-private
   "iOS sometimes return paths without the private part."
   [path]
-  (if (string/includes? path "///private/")
+  (cond
+    (string/includes? path "///private/")
     path
+
+    (string/includes? path "///")
     (let [[prefix others] (string/split path "///")]
-      (str prefix "///private/" others))))
+      (str prefix "///private/" others))
+
+    :else
+    (do
+      (state/pub-event! [:instrument {:type :error/ios-path-missing-slashes
+                                      ;; respect user's privacy
+                                      :path (gp-util/safe-subs path 10)}])
+      path)))
 
 (defn normalize-file-protocol-path [dir path]
   (let [dir             (some-> dir (string/replace #"/+$" ""))