Skip to content

Commit

Permalink
Fail early when trying to read metadata from an inaccessible file
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Aug 9, 2024
1 parent cb76b0a commit 709376d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sources/soundsourceproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,13 @@ SoundSourceProxy::UpdateTrackFromSourceResult SoundSourceProxy::updateTrackFromS
mixxx::TrackMetadata trackMetadata =
m_pTrack->getMetadata(&sourceSyncStatus);

if (sourceSyncStatus == mixxx::TrackRecord::SourceSyncStatus::Undefined) {
kLogger.warning()
<< "Unable to update track from missing or inaccessible file"
<< getUrl().toString();
return UpdateTrackFromSourceResult::NotUpdated;
}

// Save for later to replace the unreliable and imprecise audio
// properties imported from file tags (see below).
const auto preciseStreamInfo = trackMetadata.getStreamInfo();
Expand Down
6 changes: 6 additions & 0 deletions src/track/trackrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ TrackRecord::SourceSyncStatus TrackRecord::checkSourceSyncStatus(
// 37 don't have a synchronization time stamp.
return SourceSyncStatus::Unknown;
}
if (!fileInfo.exists()) {
kLogger.warning()
<< "Failed to obtain synchronization time stamp for not existing file"
<< mixxx::FileInfo(fileInfo);
return SourceSyncStatus::Undefined;
}
const QDateTime fileSourceSynchronizedAt =
MetadataSource::getFileSynchronizedAt(fileInfo.toQFile());
if (!fileSourceSynchronizedAt.isValid()) {
Expand Down

0 comments on commit 709376d

Please sign in to comment.