Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'mingmingrr-master'
  • Loading branch information
toonn committed May 31, 2023
2 parents 5c0cfb0 + 4fbf8d8 commit 1a00715
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
21 changes: 10 additions & 11 deletions ranger/core/actions.py
Expand Up @@ -32,7 +32,6 @@
from ranger.ext.get_executables import get_executables
from ranger.ext.keybinding_parser import key_to_string, construct_keybinding
from ranger.ext.macrodict import MacroDict, MACRO_FAIL, macro_val
from ranger.ext.next_available_filename import next_available_filename
from ranger.ext.relative_symlink import relative_symlink
from ranger.ext.rifle import squash_flags, ASK_COMMAND
from ranger.ext.safe_path import get_safe_path
Expand Down Expand Up @@ -1567,10 +1566,10 @@ def cut(self, mode='set', narg=None, dirarg=None):
self.do_cut = True
self.ui.browser.main_column.request_redraw()

def paste_symlink(self, relative=False):
def paste_symlink(self, relative=False, make_safe_path=get_safe_path):
copied_files = self.copy_buffer
for fobj in copied_files:
new_name = next_available_filename(fobj.basename)
new_name = make_safe_path(fobj.basename)
self.notify(new_name)
try:
if relative:
Expand All @@ -1581,37 +1580,37 @@ def paste_symlink(self, relative=False):
self.notify('Failed to paste symlink: View log for more info',
bad=True, exception=ex)

def paste_hardlink(self):
def paste_hardlink(self, make_safe_path=get_safe_path):
for fobj in self.copy_buffer:
new_name = next_available_filename(fobj.basename)
new_name = make_safe_path(fobj.basename)
try:
link(fobj.path, join(self.fm.thisdir.path, new_name))
except OSError as ex:
self.notify('Failed to paste hardlink: View log for more info',
bad=True, exception=ex)

def paste_hardlinked_subtree(self):
def paste_hardlinked_subtree(self, make_safe_path=get_safe_path):
for fobj in self.copy_buffer:
try:
target_path = join(self.fm.thisdir.path, fobj.basename)
self._recurse_hardlinked_tree(fobj.path, target_path)
self._recurse_hardlinked_tree(fobj.path, target_path, make_safe_path)
except OSError as ex:
self.notify('Failed to paste hardlinked subtree: View log for more info',
bad=True, exception=ex)

def _recurse_hardlinked_tree(self, source_path, target_path):
def _recurse_hardlinked_tree(self, source_path, target_path, make_safe_path):
if isdir(source_path):
if not exists(target_path):
os.mkdir(target_path, stat(source_path).st_mode)
for item in listdir(source_path):
self._recurse_hardlinked_tree(
join(source_path, item),
join(target_path, item))
join(target_path, item),
make_safe_path)
else:
if not exists(target_path) \
or stat(source_path).st_ino != stat(target_path).st_ino:
link(source_path,
next_available_filename(target_path))
link(source_path, make_safe_path(target_path))

def paste(self, overwrite=False, append=False, dest=None, make_safe_path=get_safe_path):
""":paste
Expand Down
22 changes: 0 additions & 22 deletions ranger/ext/next_available_filename.py

This file was deleted.

0 comments on commit 1a00715

Please sign in to comment.