use test command to detect if folder
This commit is contained in:
parent
e692c4df18
commit
6bd216615d
@ -345,26 +345,22 @@ class LinuxMachine:
|
||||
self.run_command(machine_utils.get_services_command(self.get_os_name(), "disable", service),
|
||||
return_status_code=True)
|
||||
|
||||
def is_folder(self, path: str) -> bool:
|
||||
self.run_command(f"test -d {path}", return_status_code=True)
|
||||
|
||||
def move(self, source, destination, permission: int = None, owner: str = "root"):
|
||||
self.run_command(f"mv {source} {destination}", return_status_code=True)
|
||||
|
||||
if permission is not None:
|
||||
if "LXC" in str(self.__class__):
|
||||
if self.pve.connection.sftp().is_remote_dir(source):
|
||||
permission = 755
|
||||
self.run_command(f"chmod -R {permission} {destination}", return_status_code=True)
|
||||
else:
|
||||
permission = 644
|
||||
self.run_command(f"chmod {permission} {destination}", return_status_code=True)
|
||||
if self.is_folder(source):
|
||||
permission = 755
|
||||
self.run_command(f"chmod -R {permission} {destination}", return_status_code=True)
|
||||
else:
|
||||
raise NotImplementedError("Permission setting is only supported for LXC machines")
|
||||
permission = 644
|
||||
self.run_command(f"chmod {permission} {destination}", return_status_code=True)
|
||||
|
||||
if owner != "root":
|
||||
if "LXC" in str(self.__class__):
|
||||
if self.pve.connection.sftp().is_remote_dir(source):
|
||||
self.run_command(f"chown -R {owner} {destination}", return_status_code=True)
|
||||
else:
|
||||
self.run_command(f"chown {owner} {destination}", return_status_code=True)
|
||||
if self.is_folder(source):
|
||||
self.run_command(f"chown -R {owner} {destination}", return_status_code=True)
|
||||
else:
|
||||
raise NotImplementedError("Owner setting is only supported for LXC machines")
|
||||
|
||||
self.run_command(f"chown {owner} {destination}", return_status_code=True)
|
||||
|
Loading…
Reference in New Issue
Block a user