[oonib/master] Use shutil.move instead of os.rename.

commit d507cec9856a46ab1a18586d5559861662a77491 Author: Arturo Filastò <art@fuffa.org> Date: Wed Sep 3 15:38:54 2014 +0200 Use shutil.move instead of os.rename. This is needed because otherwise it will not be possible to have the reports dir on a different device other than the archive dir. When using os.rename if the dst is not on the same device as src a "OSError: [Errno 18] Invalid cross-device link" is thrown. shutil.move will by default try to use os.rename, but if it fails it will copy src to dst and then remove src. --- oonib/report/handlers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oonib/report/handlers.py b/oonib/report/handlers.py index f1d9408..4b88647 100644 --- a/oonib/report/handlers.py +++ b/oonib/report/handlers.py @@ -1,3 +1,4 @@ +import shutil import time import yaml import json @@ -76,7 +77,7 @@ class Report(object): os.mkdir(dst_path) dst_path = os.path.join(dst_path, dst_filename) - os.rename(report_filename, dst_path) + shutil.move(report_filename, dst_path) if not self.delayed_call.called: self.delayed_call.cancel()
participants (1)
-
art@torproject.org