// Move files from out_repo into tmp_out_repo
g_debug("Moving data from %s", out_repo);
-
if (g_file_test(out_repo, G_FILE_TEST_EXISTS)) {
// Delete old metadata
gchar *full_path = g_strconcat(out_repo, filename, NULL);
gchar *new_full_path = g_strconcat(tmp_out_repo, filename, NULL);
- if (g_rename(full_path, new_full_path) == -1) {
+ // Do not override new file with the old one
+ if (g_file_test(new_full_path, G_FILE_TEST_EXISTS)) {
+ g_debug("Skip move of: %s -> %s (the destination file already exists)",
+ full_path, new_full_path);
+ g_debug("Removing: %s", full_path);
+ g_remove(full_path);
+ g_free(full_path);
+ g_free(new_full_path);
+ continue;
+ }
+
+ if (g_rename(full_path, new_full_path) == -1)
g_critical("Cannot move file %s -> %s", full_path, new_full_path);
- } else {
+ else
g_debug("Moved %s -> %s", full_path, new_full_path);
- }
g_free(full_path);
g_free(new_full_path);
g_debug("Moving data from %s", cmd_options->out_repo);
if (g_file_test(cmd_options->out_repo, G_FILE_TEST_EXISTS)) {
+ // Delete old metadata
+ g_debug("Removing old metadata from %s", cmd_options->out_repo);
+ cr_remove_metadata_classic(cmd_options->out_dir, 0);
+
// Move files from out_repo to tmp_out_repo
GDir *dirp;
dirp = g_dir_open (cmd_options->out_repo, 0, NULL);
gchar *full_path = g_strconcat(cmd_options->out_repo, filename, NULL);
gchar *new_full_path = g_strconcat(cmd_options->tmp_out_repo, filename, NULL);
- if (g_rename(full_path, new_full_path) == -1) {
+ // Do not override new file with the old one
+ if (g_file_test(new_full_path, G_FILE_TEST_EXISTS)) {
+ g_debug("Skip move of: %s -> %s (the destination file already exists)",
+ full_path, new_full_path);
+ g_debug("Removing: %s", full_path);
+ g_remove(full_path);
+ g_free(full_path);
+ g_free(new_full_path);
+ continue;
+ }
+
+ if (g_rename(full_path, new_full_path) == -1)
g_critical("Cannot move file %s -> %s", full_path, new_full_path);
- } else {
+ else
g_debug("Moved %s -> %s", full_path, new_full_path);
- }
g_free(full_path);
g_free(new_full_path);