MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / UpdateFile

Method UpdateFile

src/SongUpdate.cxx:58–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56#ifdef ENABLE_DATABASE
57
58bool
59Song::UpdateFile(Storage &storage, const StorageFileInfo &info)
60{
61 assert(info.IsRegular());
62
63 const auto &relative_uri = GetURI();
64
65 TagBuilder tag_builder;
66 auto new_audio_format = AudioFormat::Undefined();
67
68 try {
69 const auto path_fs = storage.MapFS(relative_uri);
70 if (path_fs.IsNull()) {
71 Mutex mutex;
72 const auto is = storage.OpenFile(relative_uri, mutex);
73 LockWaitReady(*is);
74 if (!tag_stream_scan(*is, tag_builder,
75 &new_audio_format))
76 return false;
77 } else {
78 if (!ScanFileTagsWithGeneric(path_fs, tag_builder,
79 &new_audio_format))
80 return false;
81 }
82 } catch (...) {
83 // TODO: log or propagate I/O errors?
84 return false;
85 }
86
87 mtime = info.mtime;
88 audio_format = new_audio_format;
89 tag_builder.Commit(tag);
90 return true;
91}
92
93#ifdef ENABLE_ARCHIVE
94

Callers 2

LoadFileMethod · 0.80
UpdateSongFile2Method · 0.80

Calls 6

LockWaitReadyFunction · 0.85
tag_stream_scanFunction · 0.85
ScanFileTagsWithGenericFunction · 0.85
MapFSMethod · 0.45
OpenFileMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected