commit 583e8c61984ff6393676bc7dc9c0f71af9c5725d
parent 3ec9bf27bd6deb9d8ff3934af900892add1d1d56
Author: archiveanon <>
Date: Thu, 21 Sep 2023 03:09:14 +0000
Implement size-ordered upload
This allows us to retrieve a folder link as soon as possible.
Diffstat:
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/gofile/api.py b/src/gofile/api.py
@@ -3,6 +3,7 @@
import argparse
import collections
import enum
+import os
import pathlib
from typing import Generic, Iterator, Optional, TypeVar
@@ -141,6 +142,12 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument("path", type=pathlib.Path, help="Path to single file or folder")
+ parser.add_argument(
+ "--fast-link",
+ action="store_true",
+ help="Uploads are queued in ascending size to get a download link as fast as possible",
+ )
+
args = parser.parse_args()
upload = None
@@ -149,8 +156,14 @@ def main():
print(f"Path '{args.path}' does not exist")
return
elif args.path.is_dir():
- results = upload_multiple(args.path.glob("*"))
- upload, *other_uploads = results
+ files = args.path.glob("*")
+
+ if args.fast_link:
+ # sort by ascending size so we can produce a link as fast as possible
+ files = sorted(files, key=lambda x: os.stat(x).st_size)
+
+ for upload in upload_multiple(files):
+ print(upload)
elif args.path.is_file():
upload = upload_single(args.path)