AgregoreWeb / agregore-browser

A minimal browser for the distributed web (Desktop version)
https://www.youtube.com/watch?v=TnYKvOQB0ts&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=14
GNU Affero General Public License v3.0
752 stars 66 forks source link

Creating empty folders on hyper:// protocol has incorrect path resolution behaviour #88

Open DeltaF1 opened 3 years ago

DeltaF1 commented 3 years ago

Environment

Windows 10 64-bit Agregore v1.0.0-29

Creating a new folder via the fetch interface creates a bunch of intermediate folders that seem to be relating to Agregore's installation location.

Steps to reproduce

  1. Create a new hyperdrive like so
    fetch("hyper://folder-creation-bug", {method: "PUT"});
  2. Write an empty folder to that hyperdrive
    fetch("hyper://folder-creation-bug/new-folder/", {method: "PUT"});
  3. Navigate to the hyperdrive in the browser view

    Expected behaviour

    An empty hyperdrive save for the folder "new-folder"

Actual behaviour

The hyperdrive contains a series of nested folders corresponding to agregore's install location before the newly created folder (e.g. hyper://folder-creation-bug/Users/Delta/AppData/Local/Programs/agregore-browser/new-folder/) image

Additional details

PUTting a new file into an intermediary folder like so:

fetch("hyper://folder-creation-bug/new-folder/test.json", {method: "PUT", body: "{key: 'value', foo: ['bar']}"});

produces the expected results, and creates new-folder at the root level of the hyperdrive. image

RangerMauve commented 3 years ago

Thanks for reporting this!

Not sure why it's doing that. :/ Had a theory, but the code seems to be straightforward. https://github.com/RangerMauve/dat-fetch/blob/master/index.js#L164

Should be a quick fix. Kinda swamped with work right now though so help would be appreciated.

DeltaF1 commented 3 years ago

Doing some more experiments.

fetch("hyper://folder-creation-bug/another-one/test.json", {method: "PUT", body: "['test2']"})

Produces an empty folder called "another-one" inside the /Users/Delta/AppData/... nonsense, but also correctly creates /another-one/test.json at the hyperdrive root. I think this means that archive.createWriteStream is already properly handling folder creation, and so https://github.com/RangerMauve/dat-fetch/blob/master/index.js#L166-L169 can be deleted. This only leaves the creation of empty folders to be handled.

RangerMauve commented 2 years ago

I think this is a Windows issue. A fix for this would be very much appreciated. 😅