dat icon indicating copy to clipboard operation
dat copied to clipboard

'dat create' throws permission error on Windows

Open samuelmaddock opened this issue 7 years ago • 12 comments

OS: Windows 10 Pro 64-bit (10.0, Build 14393)

$ node -v
v8.9.0

$ dat -v
13.9.2

$ dat create
Welcome to dat program!
You can turn any folder on your computer into a Dat.
A Dat is a folder with some magic.

Your dat is ready!
We will walk you creating a 'dat.json' file.
(You can skip dat.json and get started now.)

Learn more about dat.json: https://github.com/datprotocol/dat.json

Ctrl+C to exit at any time

Title:  foobar
Description:
{ Error: EPERM: operation not permitted, rename 'C:\Users\Sam\dat\dat.json.0.31154862242066184' -> 'C:\Users\Sam\dat\dat.json'
  errno: -4048,
  code: 'EPERM',
  syscall: 'rename',
  path: 'C:\\Users\\Sam\\dat\\dat.json.0.31154862242066184',
  dest: 'C:\\Users\\Sam\\dat\\dat.json' }

$ ls -lah
total 30K
drwxr-xr-x 1 Sam 197121   0 Nov  4 16:36 .
drwxr-xr-x 1 Sam 197121   0 Nov  4 16:36 ..
drwxr-xr-x 1 Sam 197121   0 Nov  4 16:36 .dat
-rw-r--r-- 1 Sam 197121  23 Nov  4 16:36 dat.json
-rw-r--r-- 1 Sam 197121 129 Nov  4 16:36 dat.json.0.31154862242066184

The dest file does get created, but the path file is never removed.

samuelmaddock avatar Nov 04 '17 20:11 samuelmaddock

Oh yeah windows has fun rules around renaming files.

okdistribute avatar Nov 05 '17 15:11 okdistribute

Same problem here. In my case, although dat.json pops up, it misses properties. Interesting "rename".

$ type dat.json.0.8658656477487074

{ "title": "Title 001", "description": "Description 001", "url": "dat://blah-blah-blah" }

$ type dat.json

{ "title": "Title 001" }

DevSidious avatar Dec 13 '17 08:12 DevSidious

Haven't quite had chance to dig into this. But error is something with toiletdb writing the temp file: https://github.com/maxogden/toiletdb/blob/master/index.js#L27

joehand avatar Dec 13 '17 18:12 joehand

Oh this may be happening if dat.json file already exists. And since toiletdb writes multiple times that would cause the missing properties.

joehand avatar Dec 13 '17 18:12 joehand

Would it work if toiletdb was modified so that if the file exists, it deletes it before renaming the tmp file?

okdistribute avatar Jan 11 '18 04:01 okdistribute

Should be fixed in Toiletdb, 1.4.1. If someone with windows can reinstall Dat and test, that'd be great =).

I'll try to add a test to this before we close it.

joehand avatar Jan 22 '18 21:01 joehand

Hi @joehand same error on Dat 13.10.0 on a Windows 10 installation. Seems like dat-json needs to upgrade to toiletdb v1.4.1 and then updgrade dat repo

carloslfu avatar Jan 24 '18 02:01 carloslfu

Hi @joehand same error on Dat 13.10.0 on a Windows 10 installation. Seems like dat-json needs to upgrade to toiletdb v1.4.1 and then updgrade dat repo

Cool, I can package up the new dependency. Was hoping someone could test with a manual installation before I update that =).

Thanks.

joehand avatar Jan 24 '18 16:01 joehand

Hi @joehand I have made a manual installation of Toiletdb on Dat and the error is still happening

carloslfu avatar Jan 24 '18 20:01 carloslfu

Hmm is it still the same EPERM error?

A few other things that may help:

  • Does it happen every time?
  • Does it happen if you have a dat.json before running dat create? What if you do not have a dat.json file?

joehand avatar Jan 24 '18 21:01 joehand

Hi @joehand, I updated to 13.10.0 and ran the original commands again. I'm getting the same results

Without a dat.json

$ dat create
Welcome to dat program!
You can turn any folder on your computer into a Dat.
A Dat is a folder with some magic.

Your dat is ready!
We will walk you through creating a 'dat.json' file.
(You can skip dat.json and get started now.)

Learn more about dat.json: https://github.com/datprotocol/dat.json

Ctrl+C to exit at any time

Title:  foobar
Description:
{ Error: EPERM: operation not permitted, rename 'C:\Users\Sam\dat\dat.json.0.6578956869769148' -> 'C:\Users\Sam\dat\dat.json'
  errno: -4048,
  code: 'EPERM',
  syscall: 'rename',
  path: 'C:\\Users\\Sam\\dat\\dat.json.0.6578956869769148',
  dest: 'C:\\Users\\Sam\\dat\\dat.json' }

With dat.json

$ dat create
Welcome to dat program!
You can turn any folder on your computer into a Dat.
A Dat is a folder with some magic.

Your dat is ready!
We will walk you through creating a 'dat.json' file.
(You can skip dat.json and get started now.)

Learn more about dat.json: https://github.com/datprotocol/dat.json

Ctrl+C to exit at any time

Title:  (foobar)
Description:
{ Error: EPERM: operation not permitted, rename 'C:\Users\Sam\dat\dat.json.0.867297938747515' -> 'C:\Users\Sam\dat\dat.json'
  errno: -4048,
  code: 'EPERM',
  syscall: 'rename',
  path: 'C:\\Users\\Sam\\dat\\dat.json.0.867297938747515',
  dest: 'C:\\Users\\Sam\\dat\\dat.json' }

$ ls -l
total 1
-rw-r--r-- 1 Sam 197121 129 Jan 29 01:39 dat.json.0.867297938747515

samuelmaddock avatar Jan 29 '18 06:01 samuelmaddock

Hmmm, thanks @samuelmaddock. Looks like I need to dig into what exactly causes this a bit more.

joehand avatar Jan 30 '18 15:01 joehand