Browse Source

*** simplify state file naming pattern

i'm not sure why i introduced the leading colons (also in the Far/Near
options), but they seem rather pointless, so do away with them.
backwards compat is preserved by using the old format for pre-existing
state files.

*** this is a rather low-value change

*** in principle, automatic renaming could be done. however, that
*** implies renaming the aux files for interrupted syncs as well.
wip/simplify-state-naming
Oswald Buddenhagen 2 years ago
parent
commit
77134c35db
  1. 2
      src/mbsync.1
  2. 17
      src/sync_state.c

2
src/mbsync.1

@ -726,7 +726,7 @@ you want to specify a directory.
.br
This option can be used outside any section for a global effect. In this case
the appended string is made up according to the pattern
\fB:\fIfar-store\fB:\fIfar-box\fB_:\fInear-store\fB:\fInear-box\fR
far-store\fB:\fIfar-box\fB_\fInear-store\fB:\fInear-box\fR
(see also \fBFieldDelimiter\fR below).
.br
(Global default: \fI$XDG_STATE_HOME/isync/\fR, with a fallback to

17
src/sync_state.c

@ -45,11 +45,26 @@ prepare_state( sync_vars_t *svars )
if (chan->sync_state) {
nfasprintf( &svars->dname, "%s%s", chan->sync_state, cnname );
} else {
char *dname, *dname2;
char c = FieldDelimiter;
char *cfname = clean_strdup( svars->box_name[F] );
nfasprintf( &svars->dname, "%s%c%s%c%s_%c%s%c%s", global_conf.sync_state,
nfasprintf( &dname, "%s%s%c%s_%s%c%s", global_conf.sync_state,
chan->stores[F]->name, c, cfname, chan->stores[N]->name, c, cnname );
nfasprintf( &dname2, "%s%c%s%c%s_%c%s%c%s", global_conf.sync_state,
c, chan->stores[F]->name, c, cfname, c, chan->stores[N]->name, c, cnname );
free( cfname );
struct stat st;
int ex = !lstat( dname, &st );
int ex2 = !lstat( dname2, &st );
if (ex2 && !ex) {
svars->dname = dname2;
free( dname );
} else {
if (ex && ex2)
warn( "Warning: both %s and %s exist; using the former.\n", dname, dname2 );
svars->dname = dname;
free( dname2 );
}
}
free( cnname );
char *s;

Loading…
Cancel
Save