Giter VIP home page Giter VIP logo

Comments (4)

mbharanya avatar mbharanya commented on August 25, 2024 1

@Rafiuth Thank you so much for the thorough investigation. This really seems interesting, if something like std::filesystem::exists() fails for such a use case.

I've just been trying to isolate if the issue only persists for network shares, and so far it seems that mounting the directory as a shared folder in VMware seems to no longer throw that error. I'll be watching it though, as it happened quite infrequently. This way it's still a "network" drive, but probably uses a different protocol than SMB.

from soggfy.

Rafiuth avatar Rafiuth commented on August 25, 2024

The "directory name is invalid" error is a bit weird, I don't think it's because of the \\?\ prefix because from what i've seen it was supported before win10. Did you ever see a check mark before on the playlist tracks?

Also, is C:\shortcuts\raid10 a symlink to the netshare or just a normal directory?

from soggfy.

mbharanya avatar mbharanya commented on August 25, 2024

@Rafiuth I created the symlink C:\shortcuts\raid10 pointing to a network share in hopes of fixing the issue. Using \\<ip>\raid10\Music had the same issue.

I do see checkmarks and most songs are able to be downloaded. The error just seems to happen for a few select songs.

from soggfy.

Rafiuth avatar Rafiuth commented on August 25, 2024

I've managed to reproduce this issue (or at least a related one) using a Samba server on WSL, but I didn't find a solution. You could workaround it by saving to some temporary path inside the VM and copying it to the NAS later.

Apparently, after calling std::filesystem::exists() on some existing file, the directory containing that file will no longer be recognized as a directory for some period of time. When Soggfy tries to save a track, the create_directories() call will throw an exception because it thinks that the path is a file and not a directory. The exception should be caught and logged as [ERR] Failed to save track, but it just crashes Spotify for me. I believe it also causes the "invalid directory name" error.

I've isolated a minimal repro which works most of the time, but the bug could be anywhere on the MSVC STL, Windows or Samba (most likely?):

//`Z:\` is a mounted netshare to a samba server running on WSL.
#include <fstream>
#include <iostream>
#include <filesystem>
#include <Windows.h>
namespace fs = std::filesystem;

int main(int argc, char* argv[]) {
    if (argc == 2) {
        fs::create_directories("Z:/Folder1/Folder 2");
        std::ofstream("Z:/Folder1/Folder 2/File 1.txt", std::ios::binary | std::ios::trunc) << "Hello World";
    }
    std::cout << "AttrsBefore: " << GetFileAttributesW(L"Z:/Folder1/Folder 2") << "\n";
    std::cout << "Exists: " << fs::exists("Z:/Folder1/Folder 2/File 1.txt") << "\n";
    std::cout << "AttrsAfter: " << GetFileAttributesW(L"Z:/Folder1/Folder 2") << "\n";
    return 0;
}

Output:

E:\repro>cl /std:c++17 Main.cpp

E:\repro>Main.exe a
AttrsBefore: 32
Exists: 1
AttrsAfter: 32

E:\repro>Main.exe
AttrsBefore: 16
Exists: 1
AttrsAfter: 16

E:\repro>Main.exe
AttrsBefore: 16
Exists: 1
AttrsAfter: 32

(about 30s wait between each run)

As per spec, 32=FILE_ATTRIBUTE_ARCHIVE and 16=FILE_ATTRIBUTE_DIRECTORY.

from soggfy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.