This tries to minimise what is written to disk (inc dirs) when
using on-demand mode. This could result in the failure to write
the buffer not being detected till later and not entirely sure
how clients might handle that.
if (ts->smt_start)
streaming_start_unref(ts->smt_start);
- free(ts->path);
+ if (ts->path)
+ free(ts->path);
free(ts);
}
streaming_target_t *timeshift_create
(streaming_target_t *out, time_t max_time)
{
- char buf[512];
timeshift_t *ts = calloc(1, sizeof(timeshift_t));
/* Must hold global lock */
lock_assert(&global_lock);
- /* Create directories */
- if (timeshift_filemgr_makedirs(timeshift_index, buf, sizeof(buf)))
- return NULL;
-
/* Setup structure */
TAILQ_INIT(&ts->files);
ts->output = out;
- ts->path = strdup(buf);
+ ts->path = NULL;
ts->max_time = max_time;
ts->state = TS_INIT;
ts->full = 0;
/* Create new file */
tsf_tmp = NULL;
if (!ts->full) {
+
+ /* Create directories */
+ if (!ts->path) {
+ if (timeshift_filemgr_makedirs(ts->id, path, sizeof(path)))
+ return NULL;
+ ts->path = strdup(path);
+ }
+
+ /* Create File */
snprintf(path, sizeof(path), "%s/tvh-%"PRItime_t, ts->path, time);
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d create file %s", ts->id, path);