Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Versions match `FIP_VERSION` in `src/version.h`.

## [Unreleased]

## [1.8.4] - 2026-11-23

### Fixed

- Dead/empty directory scan now works: foobar2000 reports local paths with a `file://` prefix, which root derivation discarded as a stream. Local paths are stripped to native form everywhere (scan roots, existence checks, dead-track detection, reports).
- Dead-track detection is no longer silently disabled for local files by the same `file://` prefix.

## [1.8.3] - 2026-10-18

### Fixed
Expand Down
22 changes: 22 additions & 0 deletions src/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ std::vector<std::string> common_scan_roots(const std::unordered_set<std::string>
return roots;
}

// foobar2000 prefixes local file paths with "file://" (e.g. file://G:\Music).
// Strip it so Win32 APIs and root derivation see the actual filesystem path.
std::string strip_file_scheme(const char *path) {
if (!path)
return {};
static const char scheme[] = "file://";
constexpr size_t n = sizeof(scheme) - 1;
const std::string s(path);
if (s.size() >= n) {
bool same = true;
for (size_t i = 0; i < n; ++i) {
if (static_cast<char>(::tolower(static_cast<unsigned char>(s[i]))) != scheme[i]) {
same = false;
break;
}
}
if (same)
return s.substr(n);
}
return s;
}

// Windows extended-length path so > MAX_PATH trees still enumerate. The \\?\
// prefix also keeps names like "[unnamed]" literal for the file APIs.
std::string extended_path(const std::string & path) {
Expand Down
4 changes: 4 additions & 0 deletions src/logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ dir_status classify_directory(const std::vector<std::string> & filenames);
// top folders to scan so empty sibling folders in the watched tree are found.
std::vector<std::string> common_scan_roots(const std::unordered_set<std::string> & dirPaths);

// foobar2000 reports local files as "file://G:\\path\\track.mp3". Strip the
// scheme so filesystem checks and scan roots see a plain native path.
std::string strip_file_scheme(const char *path);

// Windows extended-length path (\\?\ prefix) so folders deeper than MAX_PATH
// still work with Win32 file APIs and std::filesystem narrow operations.
std::string extended_path(const std::string & path);
22 changes: 11 additions & 11 deletions src/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
#include <algorithm>

std::string track_key(metadb_handle_ptr h) {
return track_key_for(h->get_path(), h->get_subsong_index());
return track_key_for(strip_file_scheme(h->get_path()).c_str(), h->get_subsong_index());
}

bool track_is_live(metadb_handle_ptr h, std::unordered_map<std::string, bool> *cache) {
const char *path = h->get_path();
if (strstr(path, "://") != nullptr)
return true;
const std::string path = strip_file_scheme(h->get_path());
if (path.find("://") != std::string::npos)
return true; // stream, not a local file
if (cache != nullptr) {
if (auto it = cache->find(path); it != cache->end())
return it->second;
}
const bool live = (GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES);
const bool live = (GetFileAttributesA(path.c_str()) != INVALID_FILE_ATTRIBUTES);
if (cache != nullptr)
cache->emplace(path, live);
return live;
Expand All @@ -32,7 +32,7 @@ static std::string track_header(metadb_handle_ptr h) {
if (h->format_title(nullptr, t, tf, nullptr) && !t.is_empty())
return t.c_str();
}
return h->get_path();
return strip_file_scheme(h->get_path());
}

scan_result scan_playlists() {
Expand Down Expand Up @@ -125,7 +125,7 @@ std::vector<dead_entry> scan_dead_tracks() {
e.playlistName = plname.c_str();
e.item = t;
e.header = track_header(items[t]);
e.path = items[t]->get_path();
e.path = strip_file_scheme(items[t]->get_path());
out.push_back(std::move(e));
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ std::vector<dead_entry> scan_invalid_tags() {
e.playlistName = name;
e.item = t;
e.header = track_header(items[t]);
e.path = items[t]->get_path();
e.path = strip_file_scheme(items[t]->get_path());
out.push_back(std::move(e));
}
}
Expand Down Expand Up @@ -221,10 +221,10 @@ std::vector<std::string> scan_dead_directories(std::string *diag) {
// Collect unique parent directories from all library tracks.
std::unordered_set<std::string> dirOfTrack;
for (t_size t = 0; t < all.get_count(); ++t) {
const char *path = all[t]->get_path();
if (!path)
const char *rawPath = all[t]->get_path();
if (!rawPath)
continue;
std::string dir(path);
std::string dir(strip_file_scheme(rawPath));
size_t lastSlash = dir.find_last_of("\\/");
if (lastSlash != std::string::npos)
dir = dir.substr(0, lastSlash);
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

// Single source of truth for the component version.
// Automatically updated by GitHub Actions semantic release.
#define FIP_VERSION "1.8.3"
#define FIP_VERSION "1.8.4"
12 changes: 12 additions & 0 deletions tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ static void test_record_track_playlist_match() {
CHECK_STR_EQ(reports[1].lists[0], "Favorites");
}

static void test_strip_file_scheme() {
// foobar2000 local paths arrive as file:// + native path
CHECK_STR_EQ(strip_file_scheme("file://G:\\My Drive\\Music\\track.mp3"), "G:\\My Drive\\Music\\track.mp3");
CHECK_STR_EQ(strip_file_scheme("FILE://G:/Music/track.flac"), "G:/Music/track.flac");
// streams and plain paths pass through untouched
CHECK_STR_EQ(strip_file_scheme("http://server/stream.mp3"), "http://server/stream.mp3");
CHECK_STR_EQ(strip_file_scheme("G:\\plain.mp3"), "G:\\plain.mp3");
CHECK_STR_EQ(strip_file_scheme("file://"), "");
CHECK_STR_EQ(strip_file_scheme(nullptr), "");
}

static void test_extended_path() {
// Normal drive paths get the extended-length prefix
CHECK_STR_EQ(extended_path("G:\\My Drive\\Music"), "\\\\?\\G:\\My Drive\\Music");
Expand Down Expand Up @@ -297,6 +308,7 @@ int main() {
test_classify_directory();
test_common_scan_roots();
test_extended_path();
test_strip_file_scheme();
test_derive_duplicates();
test_derive_orphans();
printf("%d checks, %d failures\n", g_checks, g_failures);
Expand Down
Loading