Parcourir la source

update cache if mod time of source file > cache's

Fabian Peter Hammerle il y a 6 ans
Parent
commit
04c05173be
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 3 1
      rgpgfs.c

+ 3 - 1
rgpgfs.c

@@ -50,7 +50,8 @@ static int rgpgfs_encrypt(const char *source_path, char *cache_path) {
   }
 
   struct stat cache_stat;
-  if (lstat(cache_path, &cache_stat)) {
+  if (lstat(cache_path, &cache_stat) ||
+      source_stat.st_mtim.tv_sec > cache_stat.st_mtim.tv_sec) {
     if (rgpgfs_mkdirs(cache_path)) {
       perror("rgpgfs_encrypt: failed to create dirs");
       return 1;
@@ -63,6 +64,7 @@ static int rgpgfs_encrypt(const char *source_path, char *cache_path) {
     }
     fprintf(cache_file, "path: %s\n", source_path);
     fprintf(cache_file, "size: %lu bytes\n", source_stat.st_size);
+    fprintf(cache_file, "mod time: %ld\n", source_stat.st_mtim.tv_sec);
     fclose(cache_file);
     printf("encrypted %s\n", source_path);
   }