about summary refs log tree commit diff stats
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
parent6dad7b9222168602c5c23fc001be290110721ec5 (diff)
downloadranger-eaed2443fa77e133809d9c47937ccd301f969fed.tar.gz
core.actions: improved fm.paste()
-rw-r--r--ranger/core/actions.py28
-rw-r--r--ranger/core/loader.py13
2 files changed, 29 insertions, 12 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)
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 28171042..85033881 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -84,11 +84,14 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 					rd, _, __ = select.select(selectlist, [], [], 0.03)
 					if rd:
 						rd = rd[0]
-						read = rd.read(512)
-						if rd == process.stderr and read:
-							self.fm.notify(read, bad=True)
-						elif rd == process.stdout and read:
-							self.stdout_buffer += read
+						if rd == process.stderr:
+							read = rd.readline()
+							if read:
+								self.fm.notify(read, bad=True)
+						elif rd == process.stdout:
+							read = rd.read(512)
+							if read:
+								self.stdout_buffer += read
 				except select.error:
 					sleep(0.03)
 		self.finished = True