Fix session-archive on macOS

By default Apple uses a private TMP folder. While mktemp
returns "/tmp/xxx" the canonical path is "/private/tmp/xxx".
This lead to issues when tmp-prefix is removed when building
the session-archive.

See also e52bdc55ad
This commit is contained in:
Robin Gareus 2021-03-17 18:05:48 +01:00
parent 71f8c8ff38
commit 48556cbd3c
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -5336,29 +5336,16 @@ Session::archive_session (const std::string& dest,
} }
/* create temporary dir to save session to */ /* create temporary dir to save session to */
#ifdef PLATFORM_WINDOWS GError* err = NULL;
char tmp[256] = "C:\\TEMP\\"; char* td = g_dir_make_tmp ("ardourarchive-XXXXXX", &err);
GetTempPath (sizeof (tmp), tmp);
#else if (!td) {
char const* tmp = getenv("TMPDIR"); error << string_compose(_("Could not make tmpdir: %1"), err->message) << endmsg;
if (!tmp) {
tmp = "/tmp/";
}
#endif
if ((strlen (tmp) + 21) > 1024) {
return -1; return -1;
} }
const string to_dir = PBD::canonical_path (td);
char tmptpl[1024]; g_free (td);
strcpy (tmptpl, tmp); g_clear_error (&err);
strcat (tmptpl, "ardourarchive-XXXXXX");
char* tmpdir = g_mkdtemp (tmptpl);
if (!tmpdir) {
return -1;
}
std::string to_dir = std::string (tmpdir);
/* switch session directory temporarily */ /* switch session directory temporarily */
(*_session_dir) = to_dir; (*_session_dir) = to_dir;