Skip to content

Commit

Permalink
Apply patch for ubuntu encrypted folder bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
titoBouzout committed Jan 7, 2014
1 parent c2b1b69 commit fb975d4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions send2trash/plat_other.py
@@ -1,7 +1,7 @@
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net) # Copyright 2010 Hardcoded Software (http://www.hardcoded.net)


# This software is licensed under the "BSD" License as described in the "LICENSE" file, # 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license


# This is a reimplementation of plat_other.py with reference to the # This is a reimplementation of plat_other.py with reference to the
Expand All @@ -19,6 +19,7 @@
import os.path as op import os.path as op
from datetime import datetime from datetime import datetime
import stat import stat
import shutil
from urllib.parse import quote from urllib.parse import quote


FILES_DIR = 'files' FILES_DIR = 'files'
Expand Down Expand Up @@ -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)): while op.exists(op.join(filespath, destname)) or op.exists(op.join(infopath, destname + INFO_SUFFIX)):
counter += 1 counter += 1
destname = '%s %s%s' % (base_name, counter, ext) destname = '%s %s%s' % (base_name, counter, ext)

check_create(filespath) check_create(filespath)
check_create(infopath) check_create(infopath)

try:
os.rename(src, op.join(filespath, destname)) 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 = open(op.join(infopath, destname + INFO_SUFFIX), 'w')
f.write(info_for(src, topdir)) f.write(info_for(src, topdir))
f.close() f.close()
Expand All @@ -93,7 +96,7 @@ def find_ext_volume_global_trash(volume_root):
trash_dir = op.join(volume_root, TOPDIR_TRASH) trash_dir = op.join(volume_root, TOPDIR_TRASH)
if not op.exists(trash_dir): if not op.exists(trash_dir):
return None return None

mode = os.lstat(trash_dir).st_mode mode = os.lstat(trash_dir).st_mode
# vol/.Trash must be a directory, cannot be a symlink, and must have the # vol/.Trash must be a directory, cannot be a symlink, and must have the
# sticky bit set. # sticky bit set.
Expand Down Expand Up @@ -137,12 +140,12 @@ def send2trash(path):
# if the file to be trashed is on the same device as HOMETRASH we # if the file to be trashed is on the same device as HOMETRASH we
# want to move it there. # want to move it there.
path_dev = get_dev(path) path_dev = get_dev(path)

# If XDG_DATA_HOME or HOMETRASH do not yet exist we need to stat the # 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. # home directory, and these paths will be created further on if needed.
trash_dev = get_dev(op.expanduser('~')) 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 topdir = XDG_DATA_HOME
dest_trash = HOMETRASH dest_trash = HOMETRASH
else: else:
Expand Down

0 comments on commit fb975d4

Please sign in to comment.