BrowserFS icon indicating copy to clipboard operation
BrowserFS copied to clipboard

AsyncMirror and Dropbox fails when there are subfolders with file

Open FredrikAleksander opened this issue 6 years ago • 4 comments

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 errmsg .

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');
    }
});

FredrikAleksander avatar Jul 31 '19 21:07 FredrikAleksander

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.

Faless avatar Mar 21 '20 13:03 Faless

(I tend to lean towards the AsyncMirror expectations).

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.

Faless avatar Mar 21 '20 13:03 Faless

@FredrikAleksander Does this bug still exist?

james-pre avatar Mar 10 '23 00:03 james-pre

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

james-pre avatar Oct 25 '23 00:10 james-pre