odeke-em/drive

Working with symlinks

asmisha opened this issue · 11 comments

Is it possible to push a symlink? Now it results in pushing an empty file.

It is, symlinks should not matter.

$ cd ~/my_drive
$ ln -s ~/Desktop/test.txt
$ drive push test.txt

In fact one of the push methods push -m uses symlinks in order to push content that isn't present in your drive, but you'd like to push from an arbitrary path on your file system. A sample usage is:

$ cd ~/my_drive/tests
$ drive push -m ~/Desktop/content ~/angstrom .

If this persists would you mind giving drive version, OS, go version, as well as a screenshot of a test?

It doesn't automatically follow symlinks though:

     $ ln -s ~/somefolder ~/mydrive/somefolder
     $ cd ~/mydrive
     $ drive push somefolder

The result is a file in Drive called somefolder. It's a 0 byte binary file where it should be a folder containing file.

Unfortunately I cannot reproduce this, even going by your steps. Please see the screenshot attached. Maybe I am missing something
screen shot 2015-03-09 at 9 07 33 am

What version of drive are you using? What OS?

Your example works for me too. The problem is actually when there is a symlink inside a subdirectory. In my case:

$ ls -lrth dim
   lrwxrwxrwx 1 root root 62 Mar  9 22:20 appm -> /home/ari/Dropbox/wits/appm
$ ls -lrth dim/appm
   -rwxrwxrwx 1 root root 302K Feb 25 18:54 LectureNotes_Student_1.pdf
   drwxrwxrwx 1 root root 4,0K Mar  4 21:52 lab2
$ drive push -ignore-conflict dim
   Resolving...
   X /dim/lab2
   + /dim/appm
   Clashing modification count 1 src: 92.00B
   Addition count 1 src: 62.00B

This results in the problem I described. I also tried drive push dim/appm but then I get errors like

/dim/appm/LectureNotes_Student_1.pdf: googleapi: Error 400: Parent is not a folder: 0B2gbvqIBh4KaMDhyczFQUTN5eE0, invalid

It would be great if you could give me information like the version of drive, OS and any other information, as previously requested.

Sorry forgot to add it's drive 0.1.1 (from Github) on Linux Mint 17.1 x64.

Alright, I'll look at it when I get home in about 10 hours.

Okay, so ReadDir when given a directory does not resolve the symlinks if they are directories. You can try to reproduce this even on your system by doing

$ mkdir -p a/b
$ mkdir -p ~/Desktop/z1/z2 && ls ~ > ~/Desktop/z1/z2/listing.txt
$ ln -s ~/Desktop/z1/z2 a/b
$ ls -R a # Should print only z2 and nothing inside it

This to me is on the OS and not a bug on drive's part. Of course I could try to mitigate this but what happens when the next user who expects system dependent behaviour?

You know what, never mind, I'll just include this in the README with caution to the user.

Please pull from master, and try again.

Fixed by 9579c28 with a contribution form @geniass. Thank you very much. Reopen if persists.