mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 08:37:14 -04:00
sshync now properly generates its config directory
This commit is contained in:
+7
-10
@@ -1,29 +1,26 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# sshync 2022.01.16.unreleased10
|
# sshync 2022.01.16.unreleased11
|
||||||
|
|
||||||
# external modules
|
# external modules
|
||||||
|
|
||||||
from os import system, remove, mkdir, walk
|
from os import system, remove, mkdir, walk
|
||||||
from os.path import getmtime, join, expanduser
|
from os.path import getmtime, join, expanduser
|
||||||
from sys import exit as s_exit
|
from sys import exit as s_exit
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
# utility functions
|
# utility functions
|
||||||
|
|
||||||
def get_titles_mods(_directory, _destination, _user_data):
|
def get_titles_mods(_directory, _destination, _user_data):
|
||||||
_title_list, _mod_list = [], []
|
_title_list, _mod_list = [], []
|
||||||
|
try: # create config directory
|
||||||
|
mkdir(expanduser('~/.config/sshync'), 0o700)
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
# local fetching
|
# local fetching
|
||||||
if _destination == 'l':
|
if _destination == 'l':
|
||||||
if Path(expanduser('~/.config/sshync/database')).is_file():
|
remove(expanduser('~/.config/sshync/database')) # assumed to exist because remote runs first
|
||||||
remove(expanduser('~/.config/sshync/database'))
|
open(expanduser('~/.config/sshync/database'), 'w') # create blank database file
|
||||||
else:
|
|
||||||
try:
|
|
||||||
mkdir(expanduser('~/.config/sshync'), 0o700)
|
|
||||||
except FileExistsError:
|
|
||||||
pass
|
|
||||||
system('touch ~/.config/sshync/database')
|
|
||||||
for _root, _directories, _files in walk(_directory):
|
for _root, _directories, _files in walk(_directory):
|
||||||
for _filename in _files:
|
for _filename in _files:
|
||||||
_title_list.append(join(_root.replace(_directory, '', 1), _filename))
|
_title_list.append(join(_root.replace(_directory, '', 1), _filename))
|
||||||
|
|||||||
Reference in New Issue
Block a user