Skip to content

Commit 46fbc37

Browse files
committed
Fix Preserve mtimes feature for Opus files
Fixes #120
1 parent 5c1bc20 commit 46fbc37

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defaults:
2828
run:
2929
shell: bash
3030
env:
31-
VCPKG_COMMITTISH: 01f602195983451bc83e72f4214af2cbc495aa94
31+
VCPKG_COMMITTISH: 10b7a178346f3f0abef60cecd5130e295afd8da4
3232

3333
jobs:
3434
build_windows:

src/scan.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ bool ScanJob::Track::scan(const Config &config, std::mutex *m)
213213
SwrContext *swr = nullptr;
214214
AVFormatContext *format_ctx = nullptr;
215215
const AVStream *stream = nullptr;
216+
if (config.preserve_mtimes) {
217+
mtime = std::make_unique<std::filesystem::file_time_type>();
218+
*mtime = std::filesystem::last_write_time(path);
219+
}
216220

217221
// For Opus files, FFmpeg always adjusts the decoded audio samples by the header output
218222
// gain with no way to disable. To get the actual loudness of the audio signal,

src/scan.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ScanJob {
5353
std::filesystem::path path;
5454
FileType type;
5555
std::unique_ptr<ebur128_state, decltype(&free_ebur128)> ebur128;
56+
std::unique_ptr<std::filesystem::file_time_type> mtime;
5657
std::string container;
5758
ScanResult result;
5859
int codec_id;

src/tag.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ static_assert((size_t) R128Tag::MAX_VAL == R128_STRING.size());
168168

169169
void tag_track(ScanJob::Track &track, const Config &config)
170170
{
171-
std::filesystem::file_time_type mtime;
172-
if (config.preserve_mtimes)
173-
mtime = std::filesystem::last_write_time(track.path);
174-
175171
switch (track.type) {
176172
case FileType::MP2:
177173
case FileType::MP3:
@@ -257,8 +253,8 @@ void tag_track(ScanJob::Track &track, const Config &config)
257253
default:
258254
break;
259255
}
260-
if (config.preserve_mtimes)
261-
std::filesystem::last_write_time(track.path, mtime);
256+
if (track.mtime)
257+
std::filesystem::last_write_time(track.path, *(track.mtime));
262258
}
263259

264260
bool tag_exists(const ScanJob::Track &track)

0 commit comments

Comments
 (0)