فهرست منبع

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

Fabian Peter Hammerle 6 سال پیش
والد
کامیت
04c05173be
1فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  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);
   }