Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
594cd294
Commit
594cd294
authored
Apr 29, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.xml backup: handle corrupted zip files
parent
e48ef298
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
slapos/format.py
slapos/format.py
+14
-1
No files found.
slapos/format.py
View file @
594cd294
...
...
@@ -42,12 +42,14 @@ import os
import
pwd
import
random
import
slapos.slap
as
slap
import
shutil
import
socket
import
struct
import
subprocess
import
sys
import
threading
import
time
import
traceback
import
zipfile
import
lxml.etree
...
...
@@ -297,7 +299,18 @@ class Computer(object):
return
if
os
.
path
.
exists
(
path_to_xml
):
self
.
backup_xml
(
path_to_archive
,
path_to_xml
)
try
:
self
.
backup_xml
(
path_to_archive
,
path_to_xml
)
except
:
# might be a corrupted zip file. let's move it out of the way and retry.
shutil
.
move
(
path_to_archive
,
path_to_archive
+
time
.
strftime
(
'_broken_%Y%m%d-%H:%M'
))
try
:
self
.
backup_xml
(
path_to_archive
,
path_to_xml
)
except
:
# give up trying
logger
.
warning
(
"Can't backup %s: %s"
%
(
path_to_xml
,
traceback
.
format_exc
()))
with
open
(
path_to_xml
,
'wb'
)
as
fout
:
fout
.
write
(
new_pretty_xml
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment