forked from ScoDoc/ScoDoc
Améliore traitement erreurs archives
This commit is contained in:
parent
c65bbc3872
commit
d21af70abb
@ -270,6 +270,10 @@ class BaseArchiver:
|
|||||||
fname = os.path.join(archive_id, filename)
|
fname = os.path.join(archive_id, filename)
|
||||||
with open(fname, "wb") as f:
|
with open(fname, "wb") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
except FileNotFoundError as exc:
|
||||||
|
raise ScoValueError(
|
||||||
|
f"Erreur stockage archive (dossier inexistant, chemin {fname})"
|
||||||
|
) from exc
|
||||||
finally:
|
finally:
|
||||||
scu.GSL.release()
|
scu.GSL.release()
|
||||||
return filename
|
return filename
|
||||||
@ -282,8 +286,13 @@ class BaseArchiver:
|
|||||||
raise ScoValueError("archive introuvable (déjà supprimée ?)")
|
raise ScoValueError("archive introuvable (déjà supprimée ?)")
|
||||||
fname = os.path.join(archive_id, filename)
|
fname = os.path.join(archive_id, filename)
|
||||||
log(f"reading archive file {fname}")
|
log(f"reading archive file {fname}")
|
||||||
|
try:
|
||||||
with open(fname, "rb") as f:
|
with open(fname, "rb") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
except FileNotFoundError as exc:
|
||||||
|
raise ScoValueError(
|
||||||
|
f"Erreur lecture archive (inexistant, chemin {fname})"
|
||||||
|
) from exc
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_archived_file(self, oid, archive_name, filename, dept_id: int = None):
|
def get_archived_file(self, oid, archive_name, filename, dept_id: int = None):
|
||||||
|
Loading…
Reference in New Issue
Block a user