BrowserFS
BrowserFS copied to clipboard
AsyncMirror and Dropbox fails when there are subfolders with file
When using AsyncMirror and Dropbox, and there are subfolders with files, it fails during configure. In the error, it seems to try and fetch but uses the subfolder path twice
.
I'm running the latest code from the master branch
A simple way to reproduce this error is by using this code in a web page, waiting for it to write the changes, and reload the page.
var dbx = new Dropbox.Dropbox({ fetch, accessToken: 'REDACTED' });
BrowserFS.configure({
fs: "AsyncMirror",
options: {
sync: { fs: "InMemory" },
async: {
fs: "Dropbox",
options: {
client: dbx
}
}
}
}, function (err) {
if (err) { console.log(err); return; }
var fs = BrowserFS.BFSRequire('fs');
if(!fs.existsSync('/subfolder')) {
fs.mkdirSync('/subfolder');
fs.writeFileSync('/subfolder/somefile.txt', 'hello world');
}
});
I can confirm this issue, after some debugging, it seems the reason for this is that Dropbox returns the absolute path of the file when listing directories.
The AsyncMirror instead, seems to expect each entry to be the relative path to the listed directory.
I'm pretty new to the codebase, so I'm not sure which behaviour is supposed to be correct (I tend to lean towards the AsyncMirror expectations). I'll dig further.
(I tend to lean towards the
AsyncMirrorexpectations).
Yep, official doc says
where files is an array of the names of the files in the directory excluding '.' and '..'.
so the correct behaviour is relative path. I'll look into a fix, hoping it does not break other Dropbox internals.
@FredrikAleksander Does this bug still exist?
Closing (stale). If you would like to reopen this issue, please do so by creating a new issue in the relevant repositories of @browser-fs