mirror of
https://github.com/arsenetar/send2trash.git
synced 2025-05-09 18:29:49 +00:00
Compare commits
No commits in common. "2aa834be94448fb3b63618aad9c7c4e1ffba4bdf" and "62849fba0b71e314f0139dc371aae42b4cce5d2d" have entirely different histories.
2aa834be94
...
62849fba0b
@ -1,10 +1,6 @@
|
|||||||
Changes
|
Changes
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Version 1.8.1b0 -- 2021/09/20
|
|
||||||
-----------------------------
|
|
||||||
* Add fallback to HOMETRASH when cross device errors happen in plat_other (#26, $41, #63)
|
|
||||||
|
|
||||||
Version 1.8.0 -- 2021/08/08
|
Version 1.8.0 -- 2021/08/08
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ from __future__ import unicode_literals
|
|||||||
import errno
|
import errno
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import os.path as op
|
import os.path as op
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import stat
|
import stat
|
||||||
@ -96,7 +95,7 @@ def check_create(dir):
|
|||||||
os.makedirs(dir, 0o700)
|
os.makedirs(dir, 0o700)
|
||||||
|
|
||||||
|
|
||||||
def trash_move(src, dst, topdir=None, cross_dev=False):
|
def trash_move(src, dst, topdir=None):
|
||||||
filename = op.basename(src)
|
filename = op.basename(src)
|
||||||
filespath = op.join(dst, FILES_DIR)
|
filespath = op.join(dst, FILES_DIR)
|
||||||
infopath = op.join(dst, INFO_DIR)
|
infopath = op.join(dst, INFO_DIR)
|
||||||
@ -113,18 +112,14 @@ def trash_move(src, dst, topdir=None, cross_dev=False):
|
|||||||
|
|
||||||
with open(op.join(infopath, destname + INFO_SUFFIX), "w") as f:
|
with open(op.join(infopath, destname + INFO_SUFFIX), "w") as f:
|
||||||
f.write(info_for(src, topdir))
|
f.write(info_for(src, topdir))
|
||||||
destpath = op.join(filespath, destname)
|
os.rename(src, op.join(filespath, destname))
|
||||||
if cross_dev:
|
|
||||||
shutil.move(src, destpath)
|
|
||||||
else:
|
|
||||||
os.rename(src, destpath)
|
|
||||||
|
|
||||||
|
|
||||||
def find_mount_point(path):
|
def find_mount_point(path):
|
||||||
# Even if something's wrong, "/" is a mount point, so the loop will exit.
|
# Even if something's wrong, "/" is a mount point, so the loop will exit.
|
||||||
# Use realpath in case it's a symlink
|
# Use realpath in case it's a symlink
|
||||||
path = op.realpath(path) # Required to avoid infinite loop
|
path = op.realpath(path) # Required to avoid infinite loop
|
||||||
while not op.ismount(path): # Note ismount() does not always detect mounts
|
while not op.ismount(path):
|
||||||
path = op.split(path)[0]
|
path = op.split(path)[0]
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@ -211,11 +206,4 @@ def send2trash(paths):
|
|||||||
if trash_dev != path_dev:
|
if trash_dev != path_dev:
|
||||||
raise OSError("Couldn't find mount point for %s" % path)
|
raise OSError("Couldn't find mount point for %s" % path)
|
||||||
dest_trash = find_ext_volume_trash(topdir)
|
dest_trash = find_ext_volume_trash(topdir)
|
||||||
try:
|
|
||||||
trash_move(path_b, dest_trash, topdir)
|
trash_move(path_b, dest_trash, topdir)
|
||||||
except OSError as error:
|
|
||||||
# Cross link errors default back to HOMETRASH
|
|
||||||
if error.errno == errno.EXDEV:
|
|
||||||
trash_move(path_b, HOMETRASH_B, XDG_DATA_HOME, cross_dev=True)
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = Send2Trash
|
name = Send2Trash
|
||||||
version = 1.8.1b0
|
version = 1.8.0
|
||||||
url = https://github.com/arsenetar/send2trash
|
url = https://github.com/arsenetar/send2trash
|
||||||
project_urls =
|
project_urls =
|
||||||
Bug Reports = https://github.com/arsenetar/send2trash/issues
|
Bug Reports = https://github.com/arsenetar/send2trash/issues
|
||||||
|
Loading…
x
Reference in New Issue
Block a user