Unthreadify FileCopy in unsquashfs.

This commit is contained in:
Teo Mrnjavac 2014-07-28 11:55:55 +02:00
parent f44b8eb758
commit c42d021b61
2 changed files with 4 additions and 14 deletions

View File

@ -26,14 +26,12 @@ import os
import subprocess
import re
from threading import Thread
COPY_CMD = 'rsync -ar --progress %(source)s %(dest)s'
ON_POSIX = 'posix' in sys.builtin_module_names
class FileCopyThread( Thread ):
class FileCopy:
""" Update the value of the progress bar so that we get some movement """
def __init__( self, source, dest, progress_cb ):
# Environment used for executing rsync properly
@ -54,13 +52,6 @@ class FileCopyThread( Thread ):
self.progress_cb = progress_cb
super( FileCopyThread, self ).__init__()
def kill( self ):
if self.process.poll() is None:
self.process.kill()
def run( self ):
num_files_copied = 0

View File

@ -22,7 +22,7 @@ import subprocess
import tempfile
from libcalamares import *
from filecopy import FileCopyThread
from filecopy import FileCopy
class UnsquashOperation:
@ -81,9 +81,8 @@ class UnsquashOperation:
try:
subprocess.check_call( [ "mount", entry[ "source" ], entry[ "sourceDir" ], "-t", "squashfs", "-o", "loop" ] )
t = FileCopyThread( entry[ "sourceDir" ], entry[ "destination" ], self.reportProgress )
t.start()
t.join()
t = FileCopy( entry[ "sourceDir" ], entry[ "destination" ], self.reportProgress )
t.run()
finally:
subprocess.check_call( [ "umount", "-l", entry[ "sourceDir" ] ] )