db/simple/Song: rename "uri" to "filename"
This attribute is not a URI; it is just the filename without its parent directory path. To avoid confusion, let's rename it to "filename", leaving the struct without a "uri" attribute.
This commit is contained in:
parent
a727150c8d
commit
7775691965
@ -51,7 +51,7 @@ range_save(BufferedOutputStream &os, unsigned start_ms, unsigned end_ms)
|
|||||||
void
|
void
|
||||||
song_save(BufferedOutputStream &os, const Song &song)
|
song_save(BufferedOutputStream &os, const Song &song)
|
||||||
{
|
{
|
||||||
os.Format(SONG_BEGIN "%s\n", song.uri.c_str());
|
os.Format(SONG_BEGIN "%s\n", song.filename.c_str());
|
||||||
|
|
||||||
range_save(os, song.start_time.ToMS(), song.end_time.ToMS());
|
range_save(os, song.start_time.ToMS(), song.end_time.ToMS());
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ Song::UpdateFileInArchive(ArchiveFile &archive) noexcept
|
|||||||
{
|
{
|
||||||
assert(parent.device == DEVICE_INARCHIVE);
|
assert(parent.device == DEVICE_INARCHIVE);
|
||||||
|
|
||||||
std::string path_utf8(uri);
|
std::string path_utf8(filename);
|
||||||
|
|
||||||
for (const Directory *directory = &parent;
|
for (const Directory *directory = &parent;
|
||||||
directory->parent != nullptr &&
|
directory->parent != nullptr &&
|
||||||
|
@ -191,7 +191,7 @@ Directory::FindSong(const char *name_utf8) const noexcept
|
|||||||
for (auto &song : songs) {
|
for (auto &song : songs) {
|
||||||
assert(&song.parent == this);
|
assert(&song.parent == this);
|
||||||
|
|
||||||
if (song.uri == name_utf8)
|
if (song.filename == name_utf8)
|
||||||
return &song;
|
return &song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ Song::Song(DetachedSong &&other, Directory &_parent) noexcept
|
|||||||
mtime(other.GetLastModified()),
|
mtime(other.GetLastModified()),
|
||||||
start_time(other.GetStartTime()),
|
start_time(other.GetStartTime()),
|
||||||
end_time(other.GetEndTime()),
|
end_time(other.GetEndTime()),
|
||||||
uri(other.GetURI())
|
filename(other.GetURI())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,17 +38,17 @@ std::string
|
|||||||
Song::GetURI() const noexcept
|
Song::GetURI() const noexcept
|
||||||
{
|
{
|
||||||
if (parent.IsRoot())
|
if (parent.IsRoot())
|
||||||
return uri;
|
return filename;
|
||||||
else {
|
else {
|
||||||
const char *path = parent.GetPath();
|
const char *path = parent.GetPath();
|
||||||
return PathTraitsUTF8::Build(path, uri.c_str());
|
return PathTraitsUTF8::Build(path, filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LightSong
|
LightSong
|
||||||
Song::Export() const noexcept
|
Song::Export() const noexcept
|
||||||
{
|
{
|
||||||
LightSong dest(uri.c_str(), tag);
|
LightSong dest(filename.c_str(), tag);
|
||||||
if (!parent.IsRoot())
|
if (!parent.IsRoot())
|
||||||
dest.directory = parent.GetPath();
|
dest.directory = parent.GetPath();
|
||||||
dest.mtime = mtime;
|
dest.mtime = mtime;
|
||||||
|
@ -91,11 +91,11 @@ struct Song {
|
|||||||
/**
|
/**
|
||||||
* The file name.
|
* The file name.
|
||||||
*/
|
*/
|
||||||
std::string uri;
|
std::string filename;
|
||||||
|
|
||||||
template<typename U>
|
template<typename F>
|
||||||
Song(U &&_uri, Directory &_parent) noexcept
|
Song(F &&_filename, Directory &_parent) noexcept
|
||||||
:parent(_parent), uri(std::forward<U>(_uri)) {}
|
:parent(_parent), filename(std::forward<F>(_filename)) {}
|
||||||
|
|
||||||
Song(DetachedSong &&other, Directory &_parent) noexcept;
|
Song(DetachedSong &&other, Directory &_parent) noexcept;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ song_cmp(const Song &a, const Song &b) noexcept
|
|||||||
return ret < 0;
|
return ret < 0;
|
||||||
|
|
||||||
/* still no difference? compare file name */
|
/* still no difference? compare file name */
|
||||||
return IcuCollate(a.uri.c_str(), b.uri.c_str()) < 0;
|
return IcuCollate(a.filename.c_str(), b.filename.c_str()) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -76,7 +76,8 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
|
|||||||
song->mtime = info.mtime;
|
song->mtime = info.mtime;
|
||||||
|
|
||||||
FormatDefault(update_domain, "added %s/%s",
|
FormatDefault(update_domain, "added %s/%s",
|
||||||
contdir->GetPath(), song->uri.c_str());
|
contdir->GetPath(),
|
||||||
|
song->filename.c_str());
|
||||||
|
|
||||||
{
|
{
|
||||||
const ScopeDatabaseLock protect;
|
const ScopeDatabaseLock protect;
|
||||||
|
@ -81,7 +81,7 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory,
|
|||||||
directory.ForEachSongSafe([&](Song &song){
|
directory.ForEachSongSafe([&](Song &song){
|
||||||
assert(&song.parent == &directory);
|
assert(&song.parent == &directory);
|
||||||
|
|
||||||
const auto name_fs = AllocatedPath::FromUTF8(song.uri.c_str());
|
const auto name_fs = AllocatedPath::FromUTF8(song.filename.c_str());
|
||||||
if (name_fs.IsNull() || exclude_list.Check(name_fs)) {
|
if (name_fs.IsNull() || exclude_list.Check(name_fs)) {
|
||||||
editor.DeleteSong(directory, &song);
|
editor.DeleteSong(directory, &song);
|
||||||
modified = true;
|
modified = true;
|
||||||
@ -103,7 +103,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
|
|||||||
|
|
||||||
directory.ForEachSongSafe([&](Song &song){
|
directory.ForEachSongSafe([&](Song &song){
|
||||||
if (!directory_child_is_regular(storage, directory,
|
if (!directory_child_is_regular(storage, directory,
|
||||||
song.uri.c_str())) {
|
song.filename.c_str())) {
|
||||||
editor.LockDeleteSong(directory, &song);
|
editor.LockDeleteSong(directory, &song);
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user