const assetKey = hashAsset(hasher, assetFile, content);
validateAssetKey(assetKey);
if (!namespaceKeys.has(assetKey)) {
logDiff(
chalk.green(` + ${assetKey} (uploading new version of ${assetFile})`)
);
// Check if adding this asset to the bucket would push it over the KV
// bulk API limits
if (
uploadBucketSize + assetSize > MAX_BUCKET_SIZE ||
uploadBucket.length + 1 > MAX_BUCKET_KEYS
) {
// If so, record the current bucket and reset it
uploadBuckets.push(uploadBucket);
uploadBucketSize = 0;
uploadBucket = [];
}
// Update the bucket and the size counter
uploadBucketSize += assetSize;
uploadBucket.push([absAssetFile, assetKey]);
uploadCount++;
} else {
logDiff(chalk.dim(` = ${assetKey} (already uploaded ${assetFile})`));
skipCount++;
}
// Remove the key from the set so we know what we've already uploaded
namespaceKeys.delete(assetKey);
// Prevent different manifest keys on windows
const manifestKey = urlSafe(path.relative(assetDirectory, absAssetFile));
manifest[manifestKey] = assetKey;
}