about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/actions.py44
-rw-r--r--ranger/core/loader.py21
2 files changed, 34 insertions, 31 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 47b15fa6..083f0c80 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -30,7 +30,7 @@ from ranger.shared import FileManagerAware, EnvironmentAware, SettingsAware
 from ranger.gui.widgets import console_mode as cmode
 from ranger.fsobject import File
 from ranger.ext import shutil_generatorized as shutil_g
-from ranger.core.loader import LoadableObject
+from ranger.core.loader import CommandLoader
 
 class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	search_method = 'ctime'
@@ -567,6 +567,10 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		if not copied_files:
 			return
 
+		def refresh(_):
+			cwd = self.env.get_directory(original_path)
+			cwd.load_content()
+
 		original_path = self.env.cwd.path
 		try:
 			one_file = copied_files[0]
@@ -580,41 +584,19 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 				descr = "moving: " + one_file.path
 			else:
 				descr = "moving files from: " + one_file.dirname
-			def generate():
-				null = open(os.devnull, 'w')
-				process = Popen(['mv', '--backup=existing',
-					'-t', self.env.cwd.path] + \
-							[f.path for f in copied_files],
-					stdout=null, stderr=PIPE)
-				while process.poll() is None:
-					rd, _, __ = select.select(
-							[process.stderr], [], [], 0.05)
-					if rd:
-						self.notify(process.stderr.readline(), bad=True)
-					yield
-				cwd = self.env.get_directory(original_path)
-				cwd.load_content()
+			obj = CommandLoader(args=['mv', '--backup=existing',
+					'-t', self.env.cwd.path] + [f.path for f in copied_files],
+					descr=descr, end_hook=refresh)
 		else:
 			if len(copied_files) == 1:
 				descr = "copying: " + one_file.path
 			else:
 				descr = "copying files from: " + one_file.dirname
-			def generate():
-				null = open(os.devnull, 'w')
-				process = Popen(['cp', '--backup=existing', '--archive',
-					'-t', self.env.cwd.path] + \
-							[f.path for f in self.env.copy],
-					stdout=null, stderr=PIPE)
-				while process.poll() is None:
-					rd, _, __ = select.select(
-							[process.stderr], [], [], 0.05)
-					if rd:
-						self.notify(process.stderr.readline(), bad=True)
-					yield
-				cwd = self.env.get_directory(original_path)
-				cwd.load_content()
-
-		self.loader.add(LoadableObject(generate(), descr))
+			obj = CommandLoader(args=['cp', '--backup=existing', '--archive',
+					'-t', self.env.cwd.path] + [f.path for f in self.env.copy],
+					descr=descr, end_hook=refresh)
+
+		self.loader.add(obj)
 
 	def delete(self):
 		self.notify("Deleting!", duration=1)
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 4f4424e4..e4bc2d95 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -35,6 +35,27 @@ class LoadableObject(object):
 		return self.description
 
 
+class CommandLoader(LoadableObject):
+	def __init__(self, args, descr, begin_hook=None, end_hook=None):
+		self.description = descr
+		self.args = args
+		self.begin_hook = begin_hook
+		self.end_hook = end_hook
+
+	def load_generator(self):
+		process = Popen(self.args, stdout=open(os.devnull, 'w'), stderr=PIPE)
+		if self.begin_hook:
+			self.begin_hook(process)
+		while process.poll() is None:
+			rd, _, __ = select.select(
+					[process.stderr], [], [], 0.05)
+			if rd:
+				self.notify(process.stderr.readline(), bad=True)
+			yield
+		if self.end_hook(process):
+			self.end_hook(process)
+
+
 class Loader(FileManagerAware):
 	seconds_of_work_time = 0.03
 
artik.com> 2018-11-30 11:10:44 -0800 committer Kartik Agaram <vc@akkartik.com> 2018-11-30 11:13:36 -0800 4802' href='/akkartik/mu/commit/subx/examples/ex8.subx?h=main&id=ee9a9237d6324f1de1bb7150083eacf7b9af5f70'>ee9a9237 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
6ff9ce26 ^
33352536 ^

ecfbbfb5 ^
5cec03b4 ^
71eb22a5 ^
33352536 ^



b142ae9c ^
33352536 ^

1639687b ^
6323661c ^
6070c23e ^
6030d7e2 ^
33352536 ^
6030d7e2 ^
33352536 ^
6030d7e2 ^
b142ae9c ^

33352536 ^
6030d7e2 ^
ed0e64a9 ^
ecfbbfb5 ^
294a1520 ^
ee9a9237 ^
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