mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Make sync_url work relative to cwd like sane programs
This commit is contained in:
parent
9cbea5fe06
commit
ecdbca8fb6
14
sync_url.py
14
sync_url.py
@ -35,19 +35,15 @@ def main() -> None:
|
|||||||
|
|
||||||
cookie_jar.load_cookies()
|
cookie_jar.load_cookies()
|
||||||
|
|
||||||
if args.folder is not None:
|
|
||||||
folder = args.folder
|
folder = args.folder
|
||||||
# Initialize pferd at the *parent of the passed folder*
|
if args.folder is None:
|
||||||
# This is needed so Pferd's internal protections against escaping the working directory
|
|
||||||
# do not trigger (e.g. if somebody names a file in ILIAS '../../bad thing.txt')
|
|
||||||
pferd = Pferd(Path(Path(__file__).parent, folder).parent, test_run=args.test_run)
|
|
||||||
else:
|
|
||||||
# fetch course name from ilias
|
|
||||||
folder = crawler.find_element_name(args.url)
|
folder = crawler.find_element_name(args.url)
|
||||||
cookie_jar.save_cookies()
|
cookie_jar.save_cookies()
|
||||||
|
|
||||||
# Initialize pferd at the location of the script
|
# files may not escape the pferd_root with relative paths
|
||||||
pferd = Pferd(Path(__file__).parent, test_run=args.test_run)
|
# note: Path(Path.cwd, Path(folder)) == Path(folder) if it is an absolute path
|
||||||
|
pferd_root = Path(Path.cwd(), Path(folder)).parent
|
||||||
|
pferd = Pferd(pferd_root, test_run=args.test_run)
|
||||||
|
|
||||||
def dir_filter(_: Path, element: IliasElementType) -> bool:
|
def dir_filter(_: Path, element: IliasElementType) -> bool:
|
||||||
if args.no_videos:
|
if args.no_videos:
|
||||||
|
Loading…
Reference in New Issue
Block a user