Skip to content

Commit

Permalink
Ensure duration is saved to FC records
Browse files Browse the repository at this point in the history
  • Loading branch information
anantakrishna committed May 9, 2024
1 parent aab8f93 commit 63ca621
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions functions/src/FidelityCheck/FC.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,8 @@ export const importRecords = functions
}

if (row['Fidelity Checked'] !== true) {
// Removing the fidelity check from the database
if (existingRecord?.fidelityCheck)
await recordSnapshot.ref.update({
fidelityCheck: null,
file: null,
duration: null,
});

// Removing the record from the database
if (existingRecord) await recordSnapshot.ref.remove();
return 'Awaiting FC';
}

Expand Down Expand Up @@ -184,7 +178,7 @@ export const importRecords = functions
};

const duration = metadataCacheSnapshot
.child(getFileDurationPath(file))
.child(getFileDurationPath(fileReference))
.val() as number;

if (!duration) return 'Duration is not available';
Expand Down
2 changes: 1 addition & 1 deletion functions/src/metadata-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getFileMetadataPath = (file: File | StorageFileReference) =>
`${(typeof file.bucket === 'string' ? file.bucket : file.bucket.name)
.split('.')
.at(0)}/${path.basename(file.name, path.extname(file.name))}/${
file.generation
file.generation || ('metadata' in file && file.metadata.generation)
}`;

export const getFileDurationPath = (file: File | StorageFileReference) =>
Expand Down

0 comments on commit 63ca621

Please sign in to comment.