Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion node/flatpak_node_generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ async def _async_main() -> None:
action='store_true',
help='Split the sources file to fit onto GitHub.',
)
parser.add_argument(
'-S',
'--split-size',
type=int,
default=49 * 1000, # GITHUB has 49MB limit.
dest='split_size',
help='If splitting the sources file, split at this size in KB. Default is 49000KB.',
)
parser.add_argument(
'--node-chromedriver-from-electron',
help='Use the ChromeDriver version associated with the given '
Expand Down Expand Up @@ -206,6 +214,7 @@ async def _async_main() -> None:
print(f'{len(packages)} packages read.')

gen = ManifestGenerator()
gen.split_size = args.split_size * 1000
with gen:
options = SpecialSourceProvider.Options(
node_chromedriver_from_electron=args.node_chromedriver_from_electron
Expand Down Expand Up @@ -267,7 +276,7 @@ async def _async_main() -> None:
indent=ManifestGenerator.JSON_INDENT,
)

if fp.tell() >= ManifestGenerator.MAX_GITHUB_SIZE:
if fp.tell() >= gen.split_size:
print(
'WARNING: generated-sources.json is too large for GitHub.',
file=sys.stderr,
Expand Down
4 changes: 2 additions & 2 deletions node/flatpak_node_generator/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@


class ManifestGenerator(ContextManager['ManifestGenerator']):
MAX_GITHUB_SIZE = 49 * 1000 * 1000
JSON_INDENT = 4

def __init__(self) -> None:
# Store the dicts as a set of tuples, then rebuild the dict when returning it.
# That way, we ensure uniqueness.
self._sources: Set[Tuple[Tuple[str, Any], ...]] = set()
self._commands: List[str] = []
self.split_size = 49 * 1000 * 1000

def __exit__(
self,
Expand Down Expand Up @@ -66,7 +66,7 @@ def split_sources(self) -> Iterator[List[Dict[Any, Any]]]:
# opening brackets.
source_json = json.dumps([source], indent=ManifestGenerator.JSON_INDENT)
source_json_len = len('\n'.join(source_json.splitlines()[1:-1]))
if current_size + source_json_len >= ManifestGenerator.MAX_GITHUB_SIZE:
if current_size + source_json_len >= self.split_size:
yield current
current = []
current_size = BASE_CURRENT_SIZE
Expand Down