about summary refs log tree commit diff stats
path: root/ranger/core/actions.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-12 03:33:26 +0200
committerhut <hut@lavabit.com>2010-10-12 03:33:26 +0200
commiteaed2443fa77e133809d9c47937ccd301f969fed (patch)
tree5da9d7c447e0b3a967a857f8982d81b1acb99079 /ranger/core/actions.py
parent6dad7b9222168602c5c23fc001be290110721ec5 (diff)
downloadranger-eaed2443fa77e133809d9c47937ccd301f969fed.tar.gz
core.actions: improved fm.paste()
Diffstat (limited to 'ranger/core/actions.py')
-rw-r--r--ranger/core/actions.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 2f6d2719..50c322c4 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -748,8 +748,15 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 			cwd = self.env.get_directory(original_path)
 			cwd.load_content()
 
-		original_path = self.env.cwd.path
+		cwd = self.env.cwd
+		original_path = cwd.path
 		one_file = copied_files[0]
+		if overwrite:
+			cp_flags = ['--backup=numbered', '-af', '--']
+			mv_flags = ['--backup=numbered', '-f', '--']
+		else:
+			cp_flags = ['--backup=numbered', '-a', '--']
+			mv_flags = ['--backup=numbered', '--']
 
 		if self.env.cut:
 			self.env.copy.clear()
@@ -758,17 +765,24 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 				descr = "moving: " + one_file.path
 			else:
 				descr = "moving files from: " + one_file.dirname
-			obj = CommandLoader(args=['mv', '--backup=existing',
-					'--suffix=_', '-ft', self.env.cwd.path] + \
-					[f.path for f in copied_files], descr=descr)
+			obj = CommandLoader(args=['mv'] + mv_flags +
+					+ [f.path for f in copied_files]
+					+ [cwd.path], descr=descr)
 		else:
 			if len(copied_files) == 1:
 				descr = "copying: " + one_file.path
 			else:
 				descr = "copying files from: " + one_file.dirname
-			obj = CommandLoader(args=['cp', '--backup=existing', '--archive',
-					'--suffix=_', '-frt', self.env.cwd.path] + \
-					[f.path for f in self.env.copy], descr=descr)
+			if not overwrite and len(copied_files) == 1 \
+					and one_file.dirname == cwd.path:
+				# Special case: yypp
+				# copying a file onto itself -> create a backup
+				obj = CommandLoader(args=['cp', '-f'] + cp_flags
+						+ [one_file.path, one_file.path], descr=descr)
+			else:
+				obj = CommandLoader(args=['cp'] + cp_flags
+						+ [f.path for f in copied_files]
+						+ [cwd.path], descr=descr)
 
 		obj.signal_bind('after', refresh)
 		self.loader.add(obj)