From 67a2a877bb222447c5714d3730dd84a6940ba2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 22 Mar 2020 04:33:04 +0100 Subject: [PATCH] change creating of ~/Work --- workdirfs.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/workdirfs.py b/workdirfs.py index da934eb..91a87a2 100755 --- a/workdirfs.py +++ b/workdirfs.py @@ -16,6 +16,8 @@ import shutil import json import traceback +from pathlib import Path + try: from fuse import FUSE, FuseOSError, Operations except: @@ -302,11 +304,21 @@ class WorkdirFS(Operations): def main(args): #FUSE(WorkdirFS(root), mountpoint, nothreads=True, foreground=True) # start FUSE filesystem - mountpoint = os.path.join(os.environ['HOME'], args.mountpoint) - if not (os.path.isdir(mountpoint) or os.path.exists(mountpoint)): - os.mkdir(mountpoint, 0o744) + mountpoint = Path(os.path.join(os.environ['HOME'], args.mountpoint)) + if mountpoint.is_link(): + mountpoint.unlink(); + if mountpoint.exist(): + mountpoint.rename(mountpoint + datetime.now().strftime("%Y-%m-%d") + + ''.join(random.choice( + string.ascii_uppercase + string.digits) for _ in range(6)) + + ".bak") + mountpoint.mkdir() +# if not (os.path.isdir(mountpoint) or os.path.exists(mountpoint)): +# if Path(mountpoint).is_symlink(): +# os.path.remove +# os.mkdir(mountpoint, 0o744) FUSE(WorkdirFS(args), os.path.join(os.environ['HOME'], args.mountpoint), - nothreads=True, foreground=True, allow_other=True, allow_root=True) + nothreads=True, foreground=True, allow_root=True) if __name__ == '__main__': #main(sys.argv[2], sys.argv[1])