[almanah/9-remove-deprecated-g-time-val] [import] Using file parsed date as last-edited date



commit 1bceb8ba624d794db224c947a5019c31dcd22227
Author: Álvaro Peña <alvaropg gmail com>
Date:   Tue May 25 23:45:24 2021 +0200

    [import] Using file parsed date as last-edited date
    
    If the imported file modification date is not valid we can use the
    file name, which has been parsed and validated already.

 src/import-operation.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/import-operation.c b/src/import-operation.c
index 3c0c34a..56657c1 100644
--- a/src/import-operation.c
+++ b/src/import-operation.c
@@ -394,8 +394,12 @@ import_text_files (AlmanahImportOperation *self, GFile *source, AlmanahImportPro
 
                /* Set the entry's last-edited date */
                modification_date_time = g_file_info_get_modification_date_time (file_info);
-               g_date_set_time_t (&last_edited, g_date_time_to_unix (modification_date_time));
-               almanah_entry_set_last_edited (entry, &last_edited);
+               if (modification_date_time != NULL) {
+                       g_date_set_time_t (&last_edited, g_date_time_to_unix (modification_date_time));
+                       almanah_entry_set_last_edited (entry, &last_edited);
+               } else {
+                       almanah_entry_set_last_edited (entry, &parsed_date);
+               }
 
                /* Store the entry */
                status = set_entry (self, entry, display_name, &message);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]