diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2025-02-28 01:43:47 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2025-02-28 01:43:47 -0500 |
commit | ba15622a751b8e67b8b62d512ad713bc408f090d (patch) | |
tree | e95173c3bc59e4e16fe42511b9cc1fd521661642 | |
parent | a7d1d6b3d9de726d303e3c98c8b43441faa1e060 (diff) | |
download | abaddon-portaudio-ba15622a751b8e67b8b62d512ad713bc408f090d.tar.gz abaddon-portaudio-ba15622a751b8e67b8b62d512ad713bc408f090d.zip |
try and resolve file name conflicts
-rw-r--r-- | src/discord/store.cpp | 13 | ||||
-rw-r--r-- | src/filecache.cpp | 5 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/discord/store.cpp b/src/discord/store.cpp index 4de5d63..506b860 100644 --- a/src/discord/store.cpp +++ b/src/discord/store.cpp @@ -3,10 +3,19 @@ using namespace std::literals::string_literals; -// hopefully the casting between signed and unsigned int64 doesnt cause issues +static std::filesystem::path MakeDBPath(bool mem_store) { + if (mem_store) { + return ":memory:"; + } else { + gchar *rand = g_uuid_string_random(); + std::string randstr = rand; + g_free(rand); + return std::filesystem::temp_directory_path() / ("abaddon-store-"s + randstr + ".db"s); + } +} Store::Store(bool mem_store) - : m_db_path(mem_store ? ":memory:" : std::filesystem::temp_directory_path() / "abaddon-store.db") + : m_db_path(MakeDBPath(mem_store)) , m_db(m_db_path.string().c_str()) { if (!m_db.OK()) { fprintf(stderr, "error opening database: %s\n", m_db.ErrStr()); diff --git a/src/filecache.cpp b/src/filecache.cpp index a107714..66787e1 100644 --- a/src/filecache.cpp +++ b/src/filecache.cpp @@ -12,7 +12,10 @@ std::string GetCachedName(const std::string &str) { } Cache::Cache() { - m_tmp_path = std::filesystem::temp_directory_path() / "abaddon-cache"; + gchar *rand = g_uuid_string_random(); + std::string randstr = rand; + g_free(rand); + m_tmp_path = std::filesystem::temp_directory_path() / ("abaddon-cache-" + randstr); std::filesystem::create_directories(m_tmp_path); m_worker.set_file_path(m_tmp_path); } |