delayed-rm 2.9.1__tar.gz → 2.9.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/PKG-INFO +1 -1
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm/delayed_rm.py +14 -20
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm.egg-info/PKG-INFO +1 -1
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/LICENSE +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/README.md +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm/__init__.py +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm/py.typed +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm.egg-info/SOURCES.txt +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm.egg-info/dependency_links.txt +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm.egg-info/entry_points.txt +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/delayed_rm.egg-info/top_level.txt +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/pyproject.toml +0 -0
- {delayed_rm-2.9.1 → delayed_rm-2.9.3}/setup.cfg +0 -0
|
@@ -3,16 +3,16 @@ from collections import defaultdict
|
|
|
3
3
|
from tempfile import gettempdir
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
from pathlib import Path
|
|
6
|
+
from os import environ
|
|
6
7
|
import subprocess
|
|
7
8
|
import argparse
|
|
8
9
|
import tempfile
|
|
9
10
|
import shutil
|
|
10
11
|
import time
|
|
11
12
|
import sys
|
|
12
|
-
import os
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
__version__ = "2.9.
|
|
15
|
+
__version__ = "2.9.3"
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
#
|
|
@@ -83,9 +83,8 @@ def _prep(paths: list[Path], rf: bool) -> list[Path]:
|
|
|
83
83
|
# Normalize paths and error checking
|
|
84
84
|
try:
|
|
85
85
|
paths = [i.parent.resolve(strict=True) / i.name for i in paths]
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
raise RMError("duplicate items passed")
|
|
86
|
+
if len(paths) != len({i.stat(follow_symlinks=False).st_ino for i in paths}):
|
|
87
|
+
raise RMError("duplicate or hardlinked items passed")
|
|
89
88
|
except (FileNotFoundError, RuntimeError) as e:
|
|
90
89
|
raise RMError(e) from e
|
|
91
90
|
for i in paths:
|
|
@@ -230,25 +229,20 @@ def delayed_rm_raw(delay: int, log: bool, r: bool, f: bool, paths: list[Path]) -
|
|
|
230
229
|
return True
|
|
231
230
|
|
|
232
231
|
|
|
233
|
-
def
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
232
|
+
def cli() -> None:
|
|
233
|
+
"""
|
|
234
|
+
delayed_rm CLI
|
|
235
|
+
"""
|
|
236
|
+
parser = argparse.ArgumentParser()
|
|
237
|
+
parser.add_argument("--version", action="version", version=f"{parser.prog} {__version__}")
|
|
237
238
|
parser.add_argument("--delay", "--ttl", type=int, default=900, help="The deletion delay in seconds")
|
|
238
239
|
parser.add_argument(
|
|
239
|
-
"--log", action="store_true", help=f"Show {
|
|
240
|
+
"--log", action="store_true", help=f"Show {parser.prog}'s log files; may not be used with other arguments"
|
|
240
241
|
)
|
|
241
242
|
parser.add_argument("-r", action="store_true", help="rm -r; must use -f with this")
|
|
242
243
|
parser.add_argument("-f", action="store_true", help="rm -f; must use -r with this")
|
|
243
244
|
parser.add_argument("paths", type=Path, nargs="*", help="The items to delete")
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
def cli() -> None:
|
|
248
|
-
"""
|
|
249
|
-
delayed_rm CLI
|
|
250
|
-
"""
|
|
251
|
-
sys.exit(main(*sys.argv))
|
|
245
|
+
sys.exit(not delayed_rm_raw(**vars(parser.parse_args())))
|
|
252
246
|
|
|
253
247
|
|
|
254
248
|
#
|
|
@@ -259,12 +253,12 @@ def cli() -> None:
|
|
|
259
253
|
def _secret_cli():
|
|
260
254
|
"""
|
|
261
255
|
This CLI is invoked on import and not will do nothing by default
|
|
262
|
-
This CLI will only
|
|
256
|
+
This CLI will only activate if argv was intentionally configured to do so
|
|
263
257
|
This entrypoint is for the spawned process to act
|
|
264
258
|
"""
|
|
265
259
|
try:
|
|
266
260
|
if len(sys.argv) == 4 and sys.argv[1] == _Secret.value:
|
|
267
|
-
if
|
|
261
|
+
if environ.get(_Secret.key, None) == _Secret.value:
|
|
268
262
|
delay = int(sys.argv[2])
|
|
269
263
|
d = Path(sys.argv[3]).resolve()
|
|
270
264
|
time.sleep(delay)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|