0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 00:17:37 +01:00
mongodb/buildscripts/validate_file_size.py
Steve McClure b4b23946cd SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254)
GitOrigin-RevId: 9d997a9f44cd43a8dec7c2a17fa2dbcd875e92f6
2024-05-16 22:07:36 +00:00

31 lines
935 B
Python

#!/usr/bin/env python3
import os
import sys
FILE_SIZE_THRESHOLD_IN_BYTES = 16 * 1024 * 1024 # 16MB
def main():
args = sys.argv[1:]
file_name = args[0]
file_path = os.path.join(os.path.dirname(os.getcwd()), file_name)
if os.path.exists(file_path):
file_size_in_bytes = os.path.getsize(file_path)
if file_size_in_bytes > FILE_SIZE_THRESHOLD_IN_BYTES:
print(
f"WARNING! {file_name} is {file_size_in_bytes} bytes, exceeding threshold"
f" {FILE_SIZE_THRESHOLD_IN_BYTES} bytes, file upload may fail due to network issues, or Evergreen"
f" may reject very large yaml sizes"
)
else:
print(
f"{file_name} is {file_size_in_bytes} bytes, below threshold {FILE_SIZE_THRESHOLD_IN_BYTES} bytes"
)
else:
print(f"{file_path} does not exist")
if __name__ == "__main__":
main()