agregore-browser icon indicating copy to clipboard operation
agregore-browser copied to clipboard

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

Open DeltaF1 opened this issue 5 years ago • 3 comments

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"});
  1. Write an empty folder to that hyperdrive
fetch("hyper://folder-creation-bug/new-folder/", {method: "PUT"});
  1. 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

DeltaF1 avatar Dec 16 '20 23:12 DeltaF1

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.

RangerMauve avatar Dec 17 '20 00:12 RangerMauve

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.

DeltaF1 avatar Dec 17 '20 09:12 DeltaF1

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

RangerMauve avatar Dec 28 '21 23:12 RangerMauve