File Optimize-server-side-file-size-change-detection.patch of Package davfs2.28634

From 745a4ebf25a459ce3bd77423cae63eded8479444 Mon Sep 17 00:00:00 2001
From: Ali Abdallah <ali.abdallah@suse.com>
Date: Thu, 21 Apr 2022 20:06:39 +0200
Subject: [PATCH] Optimize server size file size change detection

Previous fix of bsc#1188967 introduces performance issue, as the
update_cache_file is downloading the whole file on each lookup. It is
enough to get the latest file size when a file is not open or not dirty
to detect if it has been changed on the server, so next FUSE read will
have the correct size bsc#1198576.

---
 src/cache.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

--- a/src/cache.c
+++ b/src/cache.c
@@ -1034,9 +1034,23 @@ dav_lookup(dav_node **nodep, dav_node *p
         if (!(*nodep)->utime)
             update_directory(*nodep, retry);
     } else {
-        update_cache_file(*nodep);
+
         if (is_open(*nodep))
             attr_from_cache_file(*nodep);
+        else if (!is_dirty(*nodep)) {
+            int ret;
+
+            dav_props *props = NULL;
+            ret = dav_get_collection((*nodep)->path, &props);
+
+            if (ret == 0) {
+                if ((*nodep)->size != props->size) {
+                    (*nodep)->size = props->size;
+                    delete_cache_file(*nodep);
+                }
+                dav_delete_props(props);
+            }
+        }
     }
 
     return 0;
openSUSE Build Service is sponsored by