change creating of ~/Work
This commit is contained in:
parent
0c85e7d896
commit
67a2a877bb
1 changed files with 16 additions and 4 deletions
20
workdirfs.py
20
workdirfs.py
|
@ -16,6 +16,8 @@ import shutil
|
||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from fuse import FUSE, FuseOSError, Operations
|
from fuse import FUSE, FuseOSError, Operations
|
||||||
except:
|
except:
|
||||||
|
@ -302,11 +304,21 @@ class WorkdirFS(Operations):
|
||||||
def main(args):
|
def main(args):
|
||||||
#FUSE(WorkdirFS(root), mountpoint, nothreads=True, foreground=True)
|
#FUSE(WorkdirFS(root), mountpoint, nothreads=True, foreground=True)
|
||||||
# start FUSE filesystem
|
# start FUSE filesystem
|
||||||
mountpoint = os.path.join(os.environ['HOME'], args.mountpoint)
|
mountpoint = Path(os.path.join(os.environ['HOME'], args.mountpoint))
|
||||||
if not (os.path.isdir(mountpoint) or os.path.exists(mountpoint)):
|
if mountpoint.is_link():
|
||||||
os.mkdir(mountpoint, 0o744)
|
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),
|
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__':
|
if __name__ == '__main__':
|
||||||
#main(sys.argv[2], sys.argv[1])
|
#main(sys.argv[2], sys.argv[1])
|
||||||
|
|
Loading…
Reference in a new issue