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
28c884c2bea6d67910a465'>^
277ecc9e ^
9983328c ^
33cb688a ^
a1274aba ^
b42eb058 ^
b13518af ^
316ff5a9 ^
fc486c60 ^
b4934e42 ^
2c1d2db0 ^
291ca616 ^
50845f37 ^
039c03ef ^
af6658b3 ^
efe2d7a3 ^
f0df3fa5 ^
a986e2bd ^

3fe38754 ^

6a8d5d23 ^
aad61455 ^
7a268c8b ^

efdc7b16 ^
636f69d3 ^
d3c262a9 ^
cf8b174e ^
e02d47ed ^
48a8eab5 ^

4be8b401 ^



d955e3f0 ^
75013dc7 ^
67bb838c ^
a808a661 ^
bba8d293 ^
2a64495f ^
5e449699 ^
8895b130 ^

7b04e507 ^
87db0130 ^
dd4a4145 ^
8f2f1767 ^
db1721dd ^
aea5cf92 ^
b624bd94 ^
6406bf0a ^
6099d9a3 ^
9207e83c ^
f7db061b ^
6099d9a3 ^
5a8b6059 ^
6f43de0a ^




fca1fc4f ^
f70ee6b2 ^
0db4c9b2 ^
b2d63ef5 ^
6908d0cc ^
d994d0d6 ^
01c89bb5 ^
c776804d ^
dab4db44 ^
cc4210ff ^
34c131ef ^
66c5bb93 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98