This commit is contained in:
Manav Rathi 2024-04-24 11:03:49 +05:30
parent 27185c333c
commit 5b928883a6
No known key found for this signature in database
2 changed files with 9 additions and 13 deletions

View file

@ -416,21 +416,18 @@ const areLivePhotoAssets = (f: LivePhotoIdentifier, g: LivePhotoIdentifier) => {
areNotSameFileType &&
firstFileNameWithoutSuffix === secondFileNameWithoutSuffix
) {
const LIVE_PHOTO_ASSET_SIZE_LIMIT = 20 * 1024 * 1024; // 20MB
// Also check that the size of an individual Live Photo asset is less
// than an (arbitrary) limit. This should be true in practice as the
// videos for a live photo are a few seconds long. Further on, the
// zipping library that we use doesn't support stream as a input.
// checks size of live Photo assets are less than allowed limit
// I did that based on the assumption that live photo assets ideally would not be larger than LIVE_PHOTO_ASSET_SIZE_LIMIT
// also zipping library doesn't support stream as a input
if (
f.size <= LIVE_PHOTO_ASSET_SIZE_LIMIT &&
g.size <= LIVE_PHOTO_ASSET_SIZE_LIMIT
) {
const maxAssetSize = 20 * 1024 * 1024; /* 20MB */
if (f.size <= maxAssetSize && g.size <= maxAssetSize) {
return true;
} else {
log.error(
`${CustomError.TOO_LARGE_LIVE_PHOTO_ASSETS} - ${JSON.stringify({
fileSizes: [f.size, g.size],
})}`,
log.info(
`Not classifying assets with too large sizes ${[f.size, g.size]} as a live photo`,
);
}
}

View file

@ -48,7 +48,6 @@ export const CustomError = {
SUBSCRIPTION_NEEDED: "subscription not present",
NOT_FOUND: "not found ",
NO_METADATA: "no metadata",
TOO_LARGE_LIVE_PHOTO_ASSETS: "too large live photo assets",
NOT_A_DATE: "not a date",
NOT_A_LOCATION: "not a location",
FILE_ID_NOT_FOUND: "file with id not found",