Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/mm_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,28 @@ static bool mm_candidate_mount_path_exists(const mm_candidate_list_t *candidates
return false;
}

static bool mm_ensure_parent_directories(const char *path) {
char parent[PATH_MAX];
char *slash;

if (!path || path[0] == '\0')
return false;

if (!mm_copy_string(parent, sizeof(parent), path))
return false;

slash = strrchr(parent, '/');
if (!slash)
return true;

if (slash == parent)
slash[1] = '\0';
else
*slash = '\0';

return mm_ensure_dir_recursive(parent);
}

static bool mm_cleanup_mount_path(const mm_managed_mount_t *item) {
bool empty_after = false;

Expand Down Expand Up @@ -439,6 +461,12 @@ static bool mm_mount_candidate(const mm_config_t *config,
return false;
}

if (!mm_ensure_parent_directories(candidate->mount_path)) {
mm_log_error("MOUNT", "failed to create parent directories for %s: %s",
candidate->mount_path, strerror(errno));
return false;
}

if (!mm_ensure_dir_recursive(candidate->mount_path)) {
mm_log_error("MOUNT", "failed to create %s: %s", candidate->mount_path,
strerror(errno));
Expand Down
23 changes: 23 additions & 0 deletions src/mm_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@
#include "mm_sha256.h"
#include "mm_util.h"

static const time_t MM_MIN_CANDIDATE_AGE_SECONDS = 30;

static int mm_compare_candidates(const void *left, const void *right) {
const mm_image_candidate_t *a = left;
const mm_image_candidate_t *b = right;
return strcmp(a->source_path, b->source_path);
}

static bool mm_candidate_is_old_enough(const struct stat *st) {
time_t now;
double age_seconds;

if (!st)
return false;

now = time(NULL);
if (now == (time_t)-1) {
mm_log_warn("SCAN", "failed to get current time while checking candidate");
return false;
}
Comment on lines +24 to +28

age_seconds = difftime(now, st->st_mtime);
return age_seconds >= (double)MM_MIN_CANDIDATE_AGE_SECONDS;
}

static bool mm_candidate_list_contains_source(const mm_candidate_list_t *list,
const char *source_path) {
size_t index;
Expand Down Expand Up @@ -182,6 +201,10 @@ static bool mm_scan_directory(const mm_config_t *config,
continue;
if (!mm_string_ends_with_ignore_case(entry->d_name, ".ffpfsc"))
continue;
if (!mm_candidate_is_old_enough(&st)) {
mm_log_debug("SCAN", "skipping recently modified file: %s", full_path);
continue;
}
if (mm_candidate_list_contains_source(list, full_path))
continue;

Expand Down
Loading