From 996672f9625427a26bf5a0787275182bd28875fc Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Wed, 2 Nov 2022 15:29:46 +0100
Subject: [PATCH] FIX: Keep existing names and description when updating
 properties

---
 src/caoscrawler/crawl.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py
index 0883ca8f..201b01ed 100644
--- a/src/caoscrawler/crawl.py
+++ b/src/caoscrawler/crawl.py
@@ -740,6 +740,17 @@ class Crawler(object):
                     else:
                         # side effect
                         record.id = identified_record.id
+                        # Special treatment for name and description in case
+                        # they have been set in the server independently from
+                        # the crawler
+                        for attr in ["name", "description"]:
+                            if getattr(record, attr) is None:
+                                # The crawler didn't find any name or
+                                # description, i.e., not an empty one. In this
+                                # case (and only in this), keep any existing
+                                # name or description.
+                                setattr(record, attr, getattr(
+                                    identified_record, attr))
                         # Copy over checksum and size too if it is a file
                         if isinstance(record, db.File):
                             record._size = identified_record._size
-- 
GitLab