Commit aa0e252d by Luciano Barletta

cleaning is now more robust, restarting service is safer

1 parent c252d8fb
......@@ -123,10 +123,14 @@ def clean():
now = datetime.datetime.now()
for folder in paths:
# carpeta no existe, borrar mensaje
if not os.path.exists(folder):
p.deletepath(folder)
continue
mtime = os.path.getmtime(folder)
# Si la carpeta existe por más de X segundos, borrala
if int(now.strftime("%Y%m%d%H%M%S")) - int(time.strftime("%Y%m%d%H%M%S")) > operation_timer:
if os.path.exists(folder):
os.system("rm -r " + folder)
threading.Timer(clean_timer, clean).start()
......@@ -140,8 +144,7 @@ if __name__ == "__main__":
attempt()
# Demonio clean
clean()
# Borro y creo msg/ por limpieza
if os.path.exists(msgfolder):
os.system("rm -r " + msgfolder)
# creo msg/ si no existe
if not os.path.exists(msgfolder):
os.mkdir(msgfolder)
app.run("0.0.0.0")
\ No newline at end of file
......@@ -112,3 +112,6 @@ class Process:
for row in rows:
paths.append(row[0])
return paths
def deletepath(self,path):
self.conn.query("DELETE FROM msg WHERE path = ?",(path,))
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!