Skip to content

Bug: drive delete permanently deletes files instead of moving to trash #261

Description

@laihenyi

Summary

gog drive delete claims to move files to trash (as stated in its help text: "Delete a file (moves to trash)"), but actually permanently deletes files by calling the Google Drive API's files.delete endpoint, which is irreversible.

Expected Behavior

gog drive delete <fileId> should move the file to the trash (recoverable for 30 days), consistent with:

  • The help text description
  • Google Drive web UI behavior when pressing "Delete"
  • User expectations for a safe default

Actual Behavior

The command calls svc.Files.Delete(fileID) (drive.go#L557), which is the Google Drive API's permanent delete. Files are immediately and irreversibly destroyed — they do not appear in the trash.

Steps to Reproduce

# Upload a test file
gog drive upload test.txt --account user@example.com

# Delete it (expecting trash)
gog drive delete <fileId> --force --account user@example.com

# Check trash — file is NOT there, it's gone forever
# The file also returns 404 from the API
gog drive get <fileId> --account user@example.com
# → Google API error (404 notFound): File not found

Suggested Fix

  • Default drive delete should use Files.Update with Trashed: true to move to trash
  • Add a --permanent flag for users who explicitly want irreversible deletion
  • The permanent delete path should keep using Files.Delete
// Trash (default, safe)
svc.Files.Update(fileID, &drive.File{Trashed: true}).SupportsAllDrives(true).Context(ctx).Do()

// Permanent delete (opt-in with --permanent)
svc.Files.Delete(fileID).SupportsAllDrives(true).Context(ctx).Do()

Impact

This is a data loss bug. Users who rely on the documented "moves to trash" behavior cannot recover their files. The 30-day trash recovery window that Google Drive provides is completely bypassed.

Environment

  • gogcli version: v0.10.0
  • OS: macOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions