summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor V. Kovalenko <igor.v.kovalenko@gmail.com>2020-12-20 21:36:21 +0300
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>2021-01-07 23:27:16 +0000
commit4ca8997aa0a7116cc60cf375a198e3e4dad7a4e6 (patch)
tree23306bdc50e26f45124b41d8a0f922e467cc8689
parentae9d0cf307e731a02cdde38fb1632b20322f9f68 (diff)
database: drop arch from newly created database file name
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/425>
-rw-r--r--src/pulsecore/database.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/pulsecore/database.c b/src/pulsecore/database.c
index 43af6fc76..3e6f102f4 100644
--- a/src/pulsecore/database.c
+++ b/src/pulsecore/database.c
@@ -50,45 +50,47 @@ pa_database* pa_database_open(const char *path, const char *fn, bool prependmid,
return NULL;
}
- /* We include the host identifier in the file name because some database files are
- * CPU dependent, and we don't want things to go wrong if we are on a multiarch system. */
- filename_prefix = pa_sprintf_malloc("%s%s%s%s%s",
- machine_id?:"", machine_id?"-":"",
- fn,
- arch_suffix?".":"", arch_suffix?:"");
-
- /* Search for existing database directory entry name matching architecture suffix and filename suffix. */
- database_dir = opendir(path);
-
- if (database_dir) {
- for (;;) {
- errno = 0;
- de = readdir(database_dir);
- if (!de) {
- if (errno) {
- pa_log_warn("Unable to search for compatible database file, readdir() failed: %s", pa_cstrerror(errno));
- /* can continue as if there is no matching database file candidate */
+ /* Database file name starts with ${machine_id}-${fn} */
+ if (machine_id)
+ filename_prefix = pa_sprintf_malloc("%s-%s", machine_id, fn);
+ else
+ filename_prefix = pa_xstrdup(fn);
+
+ if (arch_suffix) {
+ /* Search for existing database directory entry name matching architecture suffix and filename suffix. */
+ database_dir = opendir(path);
+
+ if (database_dir) {
+ for (;;) {
+ errno = 0;
+ de = readdir(database_dir);
+ if (!de) {
+ if (errno) {
+ pa_log_warn("Unable to search for compatible database file, readdir() failed: %s", pa_cstrerror(errno));
+ /* can continue as if there is no matching database file candidate */
+ }
+
+ break;
}
- break;
- }
+ if (pa_startswith(de->d_name, filename_prefix)
+ && de->d_name[strlen(filename_prefix)] == '.'
+ && pa_startswith(de->d_name + strlen(filename_prefix) + 1, arch_suffix)
+ && pa_endswith(de->d_name + strlen(filename_prefix) + 1 + strlen(arch_suffix), filename_suffix)) {
- if (pa_startswith(de->d_name, filename_prefix) && pa_endswith(de->d_name + strlen(filename_prefix), filename_suffix)) {
- /* candidate filename found, replace filename_prefix with this one if match is not exact */
+ /* candidate filename found, replace filename_prefix with this one */
- if (strlen(de->d_name) != strlen(filename_prefix) + strlen(filename_suffix)) {
pa_log_debug("Found compatible database file '%s/%s', using it", path, de->d_name);
pa_xfree(filename_prefix);
filename_prefix = pa_xstrndup(de->d_name, strlen(de->d_name) - strlen(filename_suffix));
+ break;
}
-
- break;
}
- }
- closedir(database_dir);
- } else {
- pa_log_warn("Unable to search for compatible database file, failed to open directory %s: %s", path, pa_cstrerror(errno));
+ closedir(database_dir);
+ } else {
+ pa_log_warn("Unable to search for compatible database file, failed to open directory %s: %s", path, pa_cstrerror(errno));
+ }
}
full_path = pa_sprintf_malloc("%s" PA_PATH_SEP "%s%s", path, filename_prefix, filename_suffix);