Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Apply patch for ubuntu encrypted folder bug.

  • Loading branch information...
commit fb975d41c6f80a242e2b0dc25a7fe4ee8a6f54d4 1 parent c2b1b69
@titoBouzout authored
Showing with 11 additions and 8 deletions.
  1. +11 −8 send2trash/plat_other.py
View
19 send2trash/plat_other.py
@@ -1,7 +1,7 @@
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
-# This software is licensed under the "BSD" License as described in the "LICENSE" file,
-# which should be included with this package. The terms are also available at
+# This software is licensed under the "BSD" License as described in the "LICENSE" file,
+# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
# This is a reimplementation of plat_other.py with reference to the
@@ -19,6 +19,7 @@
import os.path as op
from datetime import datetime
import stat
+import shutil
from urllib.parse import quote
FILES_DIR = 'files'
@@ -70,11 +71,13 @@ def trash_move(src, dst, topdir=None):
while op.exists(op.join(filespath, destname)) or op.exists(op.join(infopath, destname + INFO_SUFFIX)):
counter += 1
destname = '%s %s%s' % (base_name, counter, ext)
-
+
check_create(filespath)
check_create(infopath)
-
- os.rename(src, op.join(filespath, destname))
+ try:
+ os.rename(src, op.join(filespath, destname))
+ except:
+ shutil.move(src, op.join(filespath, destname))
f = open(op.join(infopath, destname + INFO_SUFFIX), 'w')
f.write(info_for(src, topdir))
f.close()
@@ -93,7 +96,7 @@ def find_ext_volume_global_trash(volume_root):
trash_dir = op.join(volume_root, TOPDIR_TRASH)
if not op.exists(trash_dir):
return None
-
+
mode = os.lstat(trash_dir).st_mode
# vol/.Trash must be a directory, cannot be a symlink, and must have the
# sticky bit set.
@@ -137,12 +140,12 @@ def send2trash(path):
# if the file to be trashed is on the same device as HOMETRASH we
# want to move it there.
path_dev = get_dev(path)
-
+
# If XDG_DATA_HOME or HOMETRASH do not yet exist we need to stat the
# home directory, and these paths will be created further on if needed.
trash_dev = get_dev(op.expanduser('~'))
- if path_dev == trash_dev:
+ if path_dev == trash_dev or ( os.path.exists(XDG_DATA_HOME) and os.path.exists(HOMETRASH) ):
topdir = XDG_DATA_HOME
dest_trash = HOMETRASH
else:
Please sign in to comment.
Something went wrong with that request. Please try again.