mirror of https://github.com/logseq/logseq
fix(android): apply url decode before fs watcher notifies
parent
1ce4697b22
commit
7f0457f23f
|
@ -92,10 +92,23 @@ public class FsWatcher extends Plugin {
|
|||
shouldRead = true;
|
||||
}
|
||||
|
||||
URI dir = (new File(mPath)).toURI();
|
||||
URI fpath = f.toURI();
|
||||
Uri dir = Uri.fromFile(new File(mPath));
|
||||
Uri fpath = Uri.fromFile(f);
|
||||
String relpath = null;
|
||||
|
||||
obj.put("path", Normalizer.normalize(dir.relativize(fpath).toString(), Normalizer.Form.NFC));
|
||||
if (fpath.getPath().startsWith(dir.getPath())) {
|
||||
relpath = fpath.getPath().substring(dir.getPath().length());
|
||||
if (relpath.startsWith("/")) {
|
||||
relpath = relpath.substring(1);
|
||||
}
|
||||
relpath = Uri.decode(relpath);
|
||||
} else {
|
||||
Log.e("FsWatcher", "file path not under watch path");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
obj.put("path", Normalizer.normalize(relpath, Normalizer.Form.NFC));
|
||||
obj.put("dir", Uri.fromFile(new File(mPath))); // Uri is for Android. URI is for RFC compatible
|
||||
JSObject stat;
|
||||
|
||||
|
|
|
@ -1777,7 +1777,7 @@
|
|||
(when (sync-state--valid-to-accept-filewatcher-event? sync-state)
|
||||
(when (or (:mtime stat) (= type "unlink"))
|
||||
(go
|
||||
(let [path (path-normalize (remove-dir-prefix dir path))
|
||||
(let [path (path-normalize path)
|
||||
files-meta (and (not= "unlink" type)
|
||||
(<! (<get-local-files-meta
|
||||
rsapi (:current-syncing-graph-uuid sync-state) dir [path])))
|
||||
|
|
Loading…
Reference in New Issue