update_manager: fix web_deploy persistent_files
If the destination file exists it is necessary to explicitly use the filename to overwrite. Otherwise an error is generated. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
ea6df41f05
commit
3008a13efb
|
@ -60,10 +60,12 @@ class WebClientDeploy(BaseDeploy):
|
||||||
pfiles = config.getlist('persistent_files', None)
|
pfiles = config.getlist('persistent_files', None)
|
||||||
if pfiles is not None:
|
if pfiles is not None:
|
||||||
self.persistent_files = [pf.strip("/") for pf in pfiles]
|
self.persistent_files = [pf.strip("/") for pf in pfiles]
|
||||||
if ".version" in self.persistent_files:
|
for fname in (".version", "release_info.json"):
|
||||||
raise config.error(
|
if fname in self.persistent_files:
|
||||||
"Invalid value for option 'persistent_files': "
|
raise config.error(
|
||||||
"'.version' can not be persistent")
|
"Invalid value for option 'persistent_files': "
|
||||||
|
f"'{fname}' can not be persistent."
|
||||||
|
)
|
||||||
self._valid: bool = True
|
self._valid: bool = True
|
||||||
self._is_prerelease: bool = False
|
self._is_prerelease: bool = False
|
||||||
self._is_fallback: bool = False
|
self._is_fallback: bool = False
|
||||||
|
@ -361,22 +363,23 @@ class WebClientDeploy(BaseDeploy):
|
||||||
os.mkdir(persist_dir)
|
os.mkdir(persist_dir)
|
||||||
if self.path.is_dir():
|
if self.path.is_dir():
|
||||||
# find and move persistent files
|
# find and move persistent files
|
||||||
for fname in os.listdir(self.path):
|
for src_path in self.path.iterdir():
|
||||||
src_path = self.path.joinpath(fname)
|
fname = src_path.name
|
||||||
if fname in self.persistent_files:
|
if fname in self.persistent_files:
|
||||||
dest_dir = persist_dir.joinpath(fname).parent
|
dest_path = persist_dir.joinpath(fname)
|
||||||
|
dest_dir = dest_path.parent
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
shutil.move(str(src_path), str(dest_dir))
|
shutil.move(str(src_path), str(dest_path))
|
||||||
shutil.rmtree(self.path)
|
shutil.rmtree(self.path)
|
||||||
os.mkdir(self.path)
|
os.mkdir(self.path)
|
||||||
with zipfile.ZipFile(release_file) as zf:
|
with zipfile.ZipFile(release_file) as zf:
|
||||||
zf.extractall(self.path)
|
zf.extractall(self.path)
|
||||||
# Move temporary files back into
|
# Move temporary files back into
|
||||||
for fname in os.listdir(persist_dir):
|
for src_path in persist_dir.iterdir():
|
||||||
src_path = persist_dir.joinpath(fname)
|
dest_path = self.path.joinpath(src_path.name)
|
||||||
dest_dir = self.path.joinpath(fname).parent
|
dest_dir = dest_path.parent
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
shutil.move(str(src_path), str(dest_dir))
|
shutil.move(str(src_path), str(dest_path))
|
||||||
|
|
||||||
def get_update_status(self) -> Dict[str, Any]:
|
def get_update_status(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue