12. Sync

The sync command is used to sync files between the database and external files. It will iterate through the wikilinks tables and update things by comparing internal modification times.

If the external mtime is greater, the file is pushed to the table.

If the internal mtime is greater, the file is pulled from table.

If the times are equal, no action happens.

If the external file doesn't exist, it is treated as a "pull" operation.

<<argparse_entries>>=
{"sync", 4, p_sync, NULL},
<<static_funcdefs>>=
static int p_sync(int argc, char *argv[]);
<<functions>>=
static int p_sync(int argc, char *argv[])
{
    weewiki_d ww;
    int rc;

    weewiki_init(&ww);

    if (argc == 2) {
        weewiki_open(&ww, argv[1]);
    } else {
        weewiki_open(&ww, weewiki_dbname_get());
    }

    rc = weewiki_sync(&ww);

    weewiki_close(&ww);
    weewiki_clean(&ww);
    return rc;
}



prev | home | next