Browse Source

fix: only allow rmdir in bfs

Tienson Qin 4 years ago
parent
commit
ec8ddf29a8
3 changed files with 4 additions and 5 deletions
  1. 0 4
      src/electron/electron/handler.cljs
  2. 3 1
      src/main/frontend/fs.cljs
  3. 1 0
      src/main/frontend/fs/nfs.cljs

+ 0 - 4
src/electron/electron/handler.cljs

@@ -21,10 +21,6 @@
 (defmethod handle :mkdir-recur [_window [_ dir]]
   (fs/mkdirSync dir #js {:recursive true}))
 
-(defmethod handle :rmdir-recur [_window [_ dir]]
-  ;; (fs/rmdirSync dir #js {:recursive true})
-  )
-
 ;; {encoding: 'utf8', withFileTypes: true}
 (defn- readdir
   [dir]

+ 3 - 1
src/main/frontend/fs.cljs

@@ -59,7 +59,9 @@
   "Remove the directory recursively.
    Warning: only run it for browser cache."
   [dir]
-  (protocol/rmdir! (get-fs dir) dir))
+  (when-let [fs (get-fs dir)]
+    (when (= fs bfs-record)
+      (protocol/rmdir! fs dir))))
 
 (defn write-file!
   [repo dir path content opts]

+ 1 - 0
src/main/frontend/fs/nfs.cljs

@@ -96,6 +96,7 @@
                                            :error error}))))))
 
   (rmdir! [this dir]
+    ;; TOO dangerious, we should never implement this
     nil)
 
   (read-file [this dir path options]