Skip to content

Commit

Permalink
2.8.048
Browse files Browse the repository at this point in the history
  • Loading branch information
chapmanjacobd committed May 28, 2024
1 parent 1bd38dd commit 8d089d3
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 48 deletions.
5 changes: 4 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ To stop playing press Ctrl+C in either the terminal or mpv
<details><summary>List all subcommands</summary>

$ library
library (v2.8.047; 78 subcommands)
library (v2.8.048; 78 subcommands)

Create database subcommands:
╭───────────────┬──────────────────────────────────────────╮
Expand Down Expand Up @@ -1140,6 +1140,9 @@ Move files BSD-style
library merge-mv folder1 folder2/ # folder1 will go inside folder2
library merge-mv folder1/ folder2/ # folder1 will be merged with folder2

With --replace, source files with the same name as subfolders will be moved within target subfolders
but files in the destination with the same name as source subfolders will be overwritten by the folders


</details>

Expand Down
90 changes: 46 additions & 44 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion xklb/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.8.047"
__version__ = "2.8.048"
11 changes: 10 additions & 1 deletion xklb/folders/merge_mv.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ def mcp_file(args, source, destination):
except IsADirectoryError:
# attempting to replace directory with file of same name: move the file inside folder instead
destination = os.path.join(destination, os.path.basename(destination))
except PermissionError:
if os.path.isdir(destination):
# Mac OS IsADirectoryError is a PermissionError
destination = os.path.join(destination, os.path.basename(destination))
else:
print("PermissionError: skipping", source, "could not delete", destination)
return
elif args.replace is False:
print("not replacing", destination)
return
Expand Down Expand Up @@ -65,7 +72,9 @@ def merge_mv():
args.cp_args = cp_args(args)
args.destination = os.path.realpath(args.destination)

sources = (os.path.realpath(s) + ("/" if s.endswith("/") else "") for s in args.paths) # preserve trailing slash
sources = (
os.path.realpath(s) + (os.sep if s.endswith(os.sep) else "") for s in args.paths
) # preserve trailing slash
for source in sources:
if os.path.isdir(source):
for p in file_utils.rglob(source, args.ext or None)[0]:
Expand Down
4 changes: 3 additions & 1 deletion xklb/folders/mergerfs_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def mergerfs_cp():
processes.exit_error("Could not detect any mergerfs mounts")
args.srcmounts = get_srcmounts(args.mergerfs_mount)

sources = (os.path.realpath(s) + ("/" if s.endswith("/") else "") for s in args.paths) # preserve trailing slash
sources = (
os.path.realpath(s) + (os.sep if s.endswith(os.sep) else "") for s in args.paths
) # preserve trailing slash
for source in sources:
if os.path.isdir(source):
for p in file_utils.rglob(source, args.ext or None)[0]:
Expand Down
3 changes: 3 additions & 0 deletions xklb/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,9 @@ def play(action) -> str:
library merge-mv folder1 folder2/ # folder1 will go inside folder2
library merge-mv folder1/ folder2/ # folder1 will be merged with folder2
With --replace, source files with the same name as subfolders will be moved within target subfolders
but files in the destination with the same name as source subfolders will be overwritten by the folders
"""


Expand Down

0 comments on commit 8d089d3

Please sign in to comment.