odeke-em / drive

Google Drive client for the commandline
Apache License 2.0
6.69k stars 427 forks source link

drive emptytrash does nothing on Mac OS X #759

Open kklis opened 7 years ago

kklis commented 7 years ago

On Mac OS X El Captain when I do "drive emptytrash" it does nothing. It displays no message and the trash remains unemptied. go version go1.7 darwin/amd64, drive version: 0.3.8.1 Worked with v0.3.7 before upgrade to the latest release.

odeke-em commented 7 years ago

Thank you for reporting this @kklis, and welcome to drive!

Ah, I see, sounds like a regression, let me investigate this problem.

odeke-em commented 7 years ago

Umm, @kklis I just tried running empytrash and it gave me a prompt

screen shot 2016-10-10 at 6 25 05 pm
$ drive version
drive version: 0.3.8.1
Commit Hash: '7379e8ab8760037aadb28f212e4c6519638f1ea6'
Go Version: devel +964639c Sat Sep 17 14:21:32 2016 +0000
OS: darwin/amd64
BuildTime: 2016-10-10 18:22:42.971280291 -0700 PDT

Is there something am missing? Do you have a .driverc file in there?

kklis commented 7 years ago

I switched to ~/go/src/github.com/odeke-em/drive and did: git checkout v0.3.7 && make Trash gets emptied on drive emptytrash So I manually deleted the whole source directory and installed drive again with: go get -u github.com/odeke-em/drive/cmd/drive Now I can replicate the issue with: drive

odeke-em commented 7 years ago

Thanks for the feedback.

Could you install like this

$ go get github.com/odeke-em/drive/drive-gen && drive-gen

and then report what drive version says?

Also could you inspect the trash by

$ drive list --trashed --long
kklis commented 7 years ago

Thanks for further innvestigation! Here it goes: drive_gen Is it possible that the problem lies in some external dependency? Does go get -u update dependencies, too?

kklis commented 7 years ago

drive version says:

drive version: 0.3.8.1
Commit Hash: '31bff3d6d9c7710e2cae69a0efa7fd8084b98143'
Go Version: go1.7
OS: darwin/amd64
BuildTime: 2016-10-11 08:43:11.615697224 +0200 CEST
odeke-em commented 7 years ago

What does drive version say though?

odeke-em commented 7 years ago

Oh okay, thanks. Yes, go get -u updates your dependencies.

Could you do an experiment like this?

echo "aloha ola bonjour hello" | drive push --piped salut.txt
drive id salut.txt

Once you have the id of salut.txt

drive trash --id <salut.txt_id_here> && echo "Trashed successfully" || echo "failed to trash got $?"
drive list --trashed --id <salut.txt_id_here> && echo "Listed successfully" || echo "failed to list $?"
kklis commented 7 years ago

drive_trash

kklis commented 7 years ago

I can see both files salut.txt and my startrek.zip via the web interface, but drive emptytrash still does nothing.

odeke-em commented 7 years ago

hmm, and neither does drive list --trashed do anything. Can you drive untrash --id <id_of_salut> && echo "successfully untrashed" || echo "failed to untrash"?

kklis commented 7 years ago

drive_untrash

odeke-em commented 7 years ago

Now that's a real puzzle. Am almost about to catch some sleep here to get up for tomorrow work, but please feel free to hit up the source at https://github.com/odeke-em/drive/blob/master/src/trash.go#L55-L92 and I'll also mark the bug with the "Help wanted" tag.

Thanks for the patience.

kklis commented 7 years ago

I did tests with git bisect and git yields the following results:

Bisecting: 0 revisions left to test after this (roughly 0 steps)
[f3caaa06435c6c38e7eeb0f5b225181cb9335d6d] pull: allow disabling of *.desktop file creation

It seems that this is the very last commit that does not have the bug.

kklis commented 7 years ago

Confirmed, it does not work since commit:

commit 60d79c5677970ffb561e9298581662dfd19c9f43
Author: Nathaniel Baer <njbbaer@gmail.com>
Date:   Thu Jul 28 23:52:19 2016 -0700

    list: fix --trashed to return all items in the current working directory

Reverting this commit from the latest source makes drive emptytrash work again.

odeke-em commented 7 years ago

Thank you for the bissection @kklis, let me take a look at what happened there.

cinquecento commented 7 years ago

I can confirm, by reverting 60d79c5 the issue is solved.

From e1610eec60049556c2109f3c7bc6cc90affa7537 Mon Sep 17 00:00:00 2001
[...]

---
 src/list.go   | 2 ++
 src/remote.go | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/list.go b/src/list.go
index 8713f38..318f240 100644
--- a/src/list.go
+++ b/src/list.go
@@ -194,6 +194,8 @@ func (g *Commands) List(byId bool) error {
    resolver := g.rem.FindByPath
    if byId {
        resolver = g.rem.FindById
+   } else if g.opts.InTrash {
+       resolver = g.rem.FindByPathTrashed
    }

    mq := g.createMatchQuery(true)
diff --git a/src/remote.go b/src/remote.go
index 9d5133f..aa6292a 100644
--- a/src/remote.go
+++ b/src/remote.go
@@ -144,7 +144,11 @@ func (r *Remote) changes(startChangeId int64) (chan *drive.Change, error) {
 func buildExpression(parentId string, typeMask int, inTrash bool) string {
    var exprBuilder []string

-   exprBuilder = append(exprBuilder, fmt.Sprintf("'%s' in parents and trashed=%t", parentId, inTrash))
+   if inTrash || (typeMask&InTrash) != 0 {
+       exprBuilder = append(exprBuilder, "trashed=true")
+   } else {
+       exprBuilder = append(exprBuilder, fmt.Sprintf("'%s' in parents", parentId), "trashed=false")
+   }

    // Folder and NonFolder are mutually exclusive.
    if (typeMask & Folder) != 0 {
-- 
2.7.4

In practice,

$ drive version
drive version: 0.3.8.1
Commit Hash: 'e1610eec60049556c2109f3c7bc6cc90affa7537'
Go Version: go1.6.3
OS: linux/amd64
BuildTime: 2016-11-02 07:14:20.905787044 +0100 CET
$ 
$ drive push Test/
Resolving...
+ /Test/test1.file
+ /Test/test2.file
Addition count 2 src: 2.00MB
Proceed with the changes? [Y/n]:Y
 2098176 / 2098176 [===============================================] 100.00% 36s
$ 
$ drive list -trashed
$ 
$ drive trash Test/*
- /Test/test1.file
- /Test/test2.file
Deletion count 2 dest: 2.00MB
Proceed with the changes? [Y/n]:Y
 2098176 / 2098176 [================================================] 100.00% 1s
$ 
$ drive list -trashed
/test2.file
/test1.file
$ 
$ drive emptytrash
-- owner       1.00MB       <FileId>        2016-11-02 07:15:20 +0000 UTC   /My Drive/test2.file
-- owner       1.00MB       <FileId>        2016-11-02 07:15:20 +0000 UTC   /My Drive/test1.file
This operation is irreversible. Empty trash! 
Proceed with the changes? [Y/n]:Y
Successfully emptied trash
$ 
$ drive list -trashed
$ 
jcub1 commented 7 years ago

On Mac OS X Sierra when I try "go get github.com/odeke-em/drive/cmd/drive". I get the following: package github.com/odeke-em/drive/cmd/drive: mkdir /Usuarios: permission denied I put "sudo mkdir -p /data/db", but I still see the same thing, any suggestions?

juanluisbaptiste commented 7 years ago

I'm having this issue on ubuntu 16.10, with drive packages installed from the PPA. None of the commands drive emptytrash or drive ls -trashed works.

drive version: 0.3.9.1
Commit Hash: <CURRENT_COMMIT>
Go Version: <GO_VERSION>
OS: <OS_INFO>
BuildTime:
somecho commented 4 years ago

Very sorry to bump this issue, but I also have the same issue on Manjaro Linux version 5.4.60-2-MANJARO

drive version: 0.3.9.1
Commit Hash: <CURRENT_COMMIT>
Go Version: <GO_VERSION>
OS: <OS_INFO>
BuildTime:

Neither drive emptytrash or drive ls -trashed work. But I also noticed that the web client is behaving strangely. When I open up the web client and browse to trash to empty it, it doesn't empty the entire trash. In fact, it only empties the current page displaying the items in the trash and after a few seconds, the next page appears.