tom-james-watson / dat-cp

dcp | Dat Copy - remote file copy, powered by the Dat protocol
MIT License
315 stars 21 forks source link

Unable to share directories with git repos #14

Closed qubitrenegade closed 5 years ago

qubitrenegade commented 5 years ago

Hello,

I'm having a permission denied issue when trying to share a directory that has sub directories, some of those being git repos.

I was able to reproduce the issue with the following steps:

# Assume we're working from our homedir
$ cd ~
# Create containing dir, this is actually unnecessary as sharing the git project fails as well
$ mkdir test-dcp
# create a git project
$ mkdir test-dcp/test-git && cd !$
# initialize git, add readme
$ echo "Test" >> README.md && git init && git add . && git commit -a -m "The commit that started it all..." && cd ~
# Attempt to share parent directory
$ dcp -rv test-dcp
dcp DEBUG Creating dat archive.
dcp DEBUG Connecting to dat network.
dcp DEBUG Creating metadata for files:
test-dcp/test-git/.git/COMMIT_EDITMSG                         [========================================] 100% | 0s | 34.00B
test-dcp/test-git/.git/HEAD                                   [========================================] 100% | 0s | 23.00B
test-dcp/test-git/.git/config                                 [========================================] 100% | 0s | 92.00B
test-dcp/test-git/.git/description                            [========================================] 100% | 0s | 73.00B
test-dcp/test-git/.git/hooks/applypatch-msg.sample            [========================================] 100% | 0s | 478.00B
test-dcp/test-git/.git/hooks/commit-msg.sample                [========================================] 100% | 0s | 896.00B
test-dcp/test-git/.git/hooks/post-update.sample               [========================================] 100% | 0s | 189.00B
test-dcp/test-git/.git/hooks/pre-applypatch.sample            [========================================] 100% | 0s | 424.00B
test-dcp/test-git/.git/hooks/pre-commit.sample                [========================================] 100% | 0s | 1.60KB
test-dcp/test-git/.git/hooks/pre-push.sample                  [========================================] 100% | 0s | 1.32KB
test-dcp/test-git/.git/hooks/pre-rebase.sample                [========================================] 100% | 0s | 4.78KB
test-dcp/test-git/.git/hooks/pre-receive.sample               [========================================] 100% | 0s | 544.00B
test-dcp/test-git/.git/hooks/prepare-commit-msg.sample        [========================================] 100% | 0s | 1.21KB
test-dcp/test-git/.git/hooks/update.sample                    [========================================] 100% | 0s | 3.53KB
test-dcp/test-git/.git/index                                  [========================================] 100% | 0s | 137.00B
test-dcp/test-git/.git/info/exclude                           [========================================] 100% | 0s | 240.00B
test-dcp/test-git/.git/logs/HEAD                              [========================================] 100% | 0s | 189.00B
test-dcp/test-git/.git/logs/refs/heads/master                 [========================================] 100% | 0s | 189.00B
test-dcp/test-git/.git/objects/4b/825dc642cb6eb9a060e54bf8d69 [----------------------------------------] 0% | 0s | 0 / 15.00Bevents.js:167
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open 'test-dcp/test-git/.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904'
Emitted 'error' event at:
    at errorOrDestroy (internal/streams/destroy.js:98:12)
    at Duplexify.onerror (_stream_readable.js:694:7)
    at Duplexify.emit (events.js:182:13)
    at Duplexify._destroy (/home/qubitrenegade/.nvm/versions/node/v11.3.0/lib/node_modules/dat-cp/node_modules/duplexify/index.js:191:15)
    at /home/qubitrenegade/.nvm/versions/node/v11.3.0/lib/node_modules/dat-cp/node_modules/duplexify/index.js:182:10
    at process.internalTickCallback (internal/process/next_tick.js:70:11)

I don't understand this error as there's no reason permission should be denied:

$ ls -lah test-dcp/test-git/.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
-r--r-----. 1 qubitreengade qubitrenegade 15 Nov 30 21:27 test-dcp/test-git/.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
$ cat test-dcp/test-git/.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
x+)JMU0`

note this issue occurs if I share just that dir: dcp -rv dcp-test/git-test, and does not occur if I: rm -rf dcp-test/git-test/.git

So I'm wondering if it has something to do with the content of the files and the "Permission denied" is actually a red herring?

System Stats:

$ dcp --version
0.6.7
$ node --version
v11.3.0
$ npm --version
6.4.1
$ cat /etc/*release*
CentOS Linux release 7.5.1804 (Core)
Derived from Red Hat Enterprise Linux 7.5 (Source)
NAME="CentOS Linux"
VERSION="7 (Core)"
... snip ...
$ uname -a
Linux dcp-test01 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

If there's anything else I can do to provide more info I'm happy to do so!

Anyway, no big deal. I had seen your project on reddit(?) a couple weeks ago and was looking for a reason to give it a shot. We actually have better ways of sharing git repos, but I figured you might appreciate the feed back. :)

Best Regards,

tom-james-watson commented 5 years ago

Thanks for the bug report! I'll take a look at it and see what's happening.

tom-james-watson commented 5 years ago

OK, looks like the problem is with read-only files. For some reason files that are added to the archive get touched, which is what the actual problem is. Will look into this more.

tom-james-watson commented 5 years ago

I've just published 0.6.8, which should fix this issue.