| 56 | #ifdef ENABLE_DATABASE |
| 57 | |
| 58 | bool |
| 59 | Song::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 |
no test coverage detected