mirror of https://github.com/djcb/mu.git
Change format for filenames
It seems some tools try to interpret the filename of message files, even though they shouldn't: "Do not try to extract information from unique names." In particular, they seem to interpret the first part of the name (before the first dot) as the # of seconds since the Unix epoch (ie., time(NULL)). That's not what mu/mu4e put there. So, let's conform a bit more to the expected filename (as per the maildir spec), so we're not confusing those tools.
This commit is contained in:
parent
4774429ad6
commit
a350e2047d
|
@ -750,19 +750,21 @@ mu_maildir_get_maildir_from_path (const char* path)
|
|||
static char*
|
||||
get_new_basename (void)
|
||||
{
|
||||
char date[9]; /* YYYYMMDD */
|
||||
char hostname[32]; /* should be enough...*/
|
||||
long int rnd;
|
||||
time_t now;
|
||||
time_t now;
|
||||
char hostname[64];
|
||||
|
||||
if (gethostname (hostname, sizeof(hostname)) == -1)
|
||||
memcpy (hostname, "localhost", sizeof(hostname));
|
||||
else
|
||||
hostname[sizeof(hostname)-1] = '\0';
|
||||
|
||||
now = time(NULL);
|
||||
strftime (date, sizeof(date), "%Y%m%d", localtime(&now));
|
||||
if (gethostname (hostname, sizeof(hostname)) != 0)
|
||||
memcpy (hostname, "hostname", strlen("hostname"));
|
||||
rnd = random ();
|
||||
|
||||
return g_strdup_printf ("%s-%08x-%s", date,
|
||||
(unsigned)rnd, hostname);
|
||||
return g_strdup_printf ("%u.%8x%8x.%s",
|
||||
(guint)now,
|
||||
g_random_int(),
|
||||
(gint32)g_get_monotonic_time (),
|
||||
hostname);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -481,7 +481,10 @@ test_mu_maildir_get_new_path_new (void)
|
|||
str = mu_maildir_get_new_path (paths[i].oldpath, NULL,
|
||||
paths[i].flags, TRUE);
|
||||
newbase = g_path_get_basename (str);
|
||||
assert_matches_regexp (newbase, "\\d{8}-[[:xdigit:]]{8}-[[:alpha:]]+(:2,.*)?");
|
||||
assert_matches_regexp (newbase,
|
||||
"\\d+\\."
|
||||
"[[:xdigit:]]{16}\\."
|
||||
"[[:alpha:]]+(:2,.*)?");
|
||||
g_free (newbase);
|
||||
g_free(str);
|
||||
}
|
||||
|
|
|
@ -309,9 +309,10 @@ You can append flags."
|
|||
(save-match-data
|
||||
(substring system-name
|
||||
(string-match "^[^.]+" system-name) (match-end 0))))))
|
||||
(format "%s-%02x%04x-%s:2,%s"
|
||||
(format-time-string "%Y%m%d" (current-time))
|
||||
(random 255) (random 65535) hostname (or flagstr ""))))
|
||||
(format "%s.%04x%04x%04x%04x.%s:2,%s"
|
||||
(format-time-string "%s" (current-time))
|
||||
(random 65535) (random 65535) (random 65535) (random 65535)
|
||||
hostname (or flagstr ""))))
|
||||
|
||||
(defun mu4e~draft-common-construct ()
|
||||
"Construct the common headers for each message."
|
||||
|
|
Loading…
Reference in New Issue