kopia lustrzana https://github.com/OpenDroneMap/WebODM
Delink console text on duplication
rodzic
0cc4be5829
commit
9ee1474df7
|
@ -51,3 +51,14 @@ class Console:
|
|||
f.write(text)
|
||||
except IOError:
|
||||
logger.warn("Cannot reset console file: %s" % self.file)
|
||||
|
||||
def delink(self):
|
||||
try:
|
||||
if os.path.isfile(self.file) and os.stat(self.file).st_nlink > 1:
|
||||
with open(self.file, "r", encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
os.unlink(self.file)
|
||||
with open(self.file, "w", encoding="utf-8") as f:
|
||||
f.write(text)
|
||||
except OSError:
|
||||
logger.warn("Cannot delink console file: %s" % self.file)
|
|
@ -438,6 +438,9 @@ class Task(models.Model):
|
|||
try:
|
||||
# Try to use hard links first
|
||||
shutil.copytree(self.task_path(), task.task_path(), copy_function=os.link)
|
||||
|
||||
# Make sure the console output is not linked to the original task
|
||||
task.console.delink()
|
||||
except Exception as e:
|
||||
logger.warning("Cannot duplicate task using hard links, will use normal copy instead: {}".format(str(e)))
|
||||
shutil.copytree(self.task_path(), task.task_path())
|
||||
|
|
Ładowanie…
Reference in New Issue