Cleanup
This commit is contained in:
parent
d6ec05193b
commit
1bef747306
1 changed files with 6 additions and 10 deletions
|
|
@ -668,7 +668,6 @@ class LXMessage:
|
||||||
|
|
||||||
return msgpack.packb(container)
|
return msgpack.packb(container)
|
||||||
|
|
||||||
|
|
||||||
def write_to_directory(self, directory_path):
|
def write_to_directory(self, directory_path):
|
||||||
file_name = RNS.hexrep(self.hash, delimit=False)
|
file_name = RNS.hexrep(self.hash, delimit=False)
|
||||||
file_path = directory_path+"/"+file_name
|
file_path = directory_path+"/"+file_name
|
||||||
|
|
@ -678,20 +677,17 @@ class LXMessage:
|
||||||
with open(tmp_path, "wb") as file:
|
with open(tmp_path, "wb") as file:
|
||||||
file.write(self.packed_container())
|
file.write(self.packed_container())
|
||||||
file.flush()
|
file.flush()
|
||||||
try:
|
try: os.fsync(file.fileno())
|
||||||
os.fsync(file.fileno())
|
except OSError: pass
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
os.replace(tmp_path, file_path)
|
|
||||||
|
|
||||||
|
os.replace(tmp_path, file_path)
|
||||||
return file_path
|
return file_path
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
if os.path.exists(tmp_path):
|
if os.path.exists(tmp_path): os.unlink(tmp_path)
|
||||||
os.unlink(tmp_path)
|
except Exception: pass
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
RNS.log("Error while writing LXMF message to file \""+str(file_path)+"\". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Error while writing LXMF message to file \""+str(file_path)+"\". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue