use_newer_updates_only.patch
Une mise en garde potentielle est que je ne suis pas complètement sûr que st_mtime est correctement actualiser sous tous les différents systèmes de fichiers de windows et mac, dans toutes les circonstances. Mais je ne trouve pas non plus de la documentation disant que ce ne soit pas le cas.
Sous unix il y a l'utilité practique touch pour manuellement changer le mtime.
Code : Tout sélectionner
diff --git a/io/elfilewrapper.c b/io/elfilewrapper.c
index a2b171d..d4944a8 100644
--- a/io/elfilewrapper.c
+++ b/io/elfilewrapper.c
@@ -547,6 +547,28 @@ static Uint32 file_exists_path(const char* file_name, const char* extra_path)
return 0;
}
+static int file_is_newer(const char *file_name,
+ const char *new_path,
+ const char *old_path)
+{
+ struct stat b;
+ char p[1024];
+ const size_t s = sizeof p;
+ time_t mtime_new;
+
+ safe_strncpy(p, new_path, s);
+ safe_strcat(p, file_name, s);
+ if (-1 == stat(p, &b))
+ return 0;
+ mtime_new = b.st_mtime;
+
+ safe_strncpy(p, old_path, s);
+ safe_strcat(p, file_name, s);
+ if (-1 == stat(p, &b))
+ return 1;
+ return mtime_new >= b.st_mtime;
+}
+
static el_file_ptr xz_file_open(const char* file_name)
{
el_file_ptr result;
@@ -759,7 +781,8 @@ static el_file_ptr file_open(const char* file_name, const char* extra_path)
}
}
- if (do_file_exists(file_name, get_path_updates(), sizeof(str), str) == 1)
+ if (do_file_exists(file_name, get_path_updates(), sizeof(str), str) == 1
+ && file_is_newer(file_name, get_path_updates(), datadir))
{
return xz_gz_file_open(str);
}