MSD 支持运行目录存放镜像

This commit is contained in:
mofeng-git
2024-10-05 14:31:23 +00:00
parent eca4167789
commit 507c46b986
9 changed files with 40 additions and 16 deletions

View File

@@ -52,8 +52,12 @@ def _mkdir(path: str) -> None:
os.mkdir(path)
def _chown(path: str, user: str) -> None:
get_logger().info("CHOWN --- %s - %s", user, path)
def _chown(path: str, user: str, optional: bool=False) -> None:
logger = get_logger()
if optional and not os.access(path, os.F_OK):
logger.info("CHOWN --- %s - [SKIPPED] %s", user, path)
return
logger.info("CHOWN --- %s - %s", user, path)
shutil.chown(path, user)
@@ -187,7 +191,7 @@ class _GadgetConfig:
_chown(join(func_path, "lun.0/cdrom"), user)
_chown(join(func_path, "lun.0/ro"), user)
_chown(join(func_path, "lun.0/file"), user)
_chown(join(func_path, "lun.0/forced_eject"), user)
_chown(join(func_path, "lun.0/forced_eject"), user, optional=True)
if start:
_symlink(func_path, join(self.__profile_path, func))
name = ("Mass Storage Drive" if self.__msd_instance == 0 else f"Extra Drive #{self.__msd_instance}")