[evolution-data-server] Bug 606071 - [Calendar] Preserve existing CREATED/LAST-MODIFIED on create
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 606071 - [Calendar] Preserve existing CREATED/LAST-MODIFIED on create
- Date: Fri, 19 Oct 2018 10:04:38 +0000 (UTC)
commit 6f9a306a4c9946d6c18e8f3cac3d2dd135829286
Author: Milan Crha <mcrha redhat com>
Date: Fri Oct 19 12:05:20 2018 +0200
Bug 606071 - [Calendar] Preserve existing CREATED/LAST-MODIFIED on create
Closes https://bugzilla.gnome.org/show_bug.cgi?id=606071
src/calendar/backends/file/e-cal-backend-file.c | 26 +++++++++++++++++++------
src/calendar/libedata-cal/e-cal-meta-backend.c | 13 ++++++++++---
2 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/src/calendar/backends/file/e-cal-backend-file.c b/src/calendar/backends/file/e-cal-backend-file.c
index 4ac2dd1fe..9d115cbfb 100644
--- a/src/calendar/backends/file/e-cal-backend-file.c
+++ b/src/calendar/backends/file/e-cal-backend-file.c
@@ -2292,10 +2292,17 @@ e_cal_backend_file_create_objects (ECalBackendSync *backend,
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
- /* Set the created and last modified times on the component */
+ /* Set the created and last modified times on the component, if not there already */
current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
- e_cal_component_set_created (comp, ¤t);
- e_cal_component_set_last_modified (comp, ¤t);
+
+ if (!icalcomponent_get_first_property (icalcomp, ICAL_CREATED_PROPERTY)) {
+ /* Update both when CREATED is missing, to make sure the LAST-MODIFIED
+ is not before CREATED */
+ e_cal_component_set_created (comp, ¤t);
+ e_cal_component_set_last_modified (comp, ¤t);
+ } else if (!icalcomponent_get_first_property (icalcomp, ICAL_LASTMODIFIED_PROPERTY)) {
+ e_cal_component_set_last_modified (comp, ¤t);
+ }
/* sanitize the component*/
sanitize_component (cbfile, comp);
@@ -3389,10 +3396,17 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend,
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, subcomp);
- /* Set the created and last modified times on the component */
+ /* Set the created and last modified times on the component, if not there already */
current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
- e_cal_component_set_created (comp, ¤t);
- e_cal_component_set_last_modified (comp, ¤t);
+
+ if (!icalcomponent_get_first_property (icalcomp, ICAL_CREATED_PROPERTY)) {
+ /* Update both when CREATED is missing, to make sure the LAST-MODIFIED
+ is not before CREATED */
+ e_cal_component_set_created (comp, ¤t);
+ e_cal_component_set_last_modified (comp, ¤t);
+ } else if (!icalcomponent_get_first_property (icalcomp, ICAL_LASTMODIFIED_PROPERTY)) {
+ e_cal_component_set_last_modified (comp, ¤t);
+ }
e_cal_component_get_uid (comp, &uid);
rid = e_cal_component_get_recurid_as_string (comp);
diff --git a/src/calendar/libedata-cal/e-cal-meta-backend.c b/src/calendar/libedata-cal/e-cal-meta-backend.c
index 2f15bc6fa..f0ce94a6f 100644
--- a/src/calendar/libedata-cal/e-cal-meta-backend.c
+++ b/src/calendar/libedata-cal/e-cal-meta-backend.c
@@ -1592,10 +1592,17 @@ ecmb_create_object_sync (ECalMetaBackend *meta_backend,
return FALSE;
}
- /* Set the created and last modified times on the component */
+ /* Set the created and last modified times on the component, if not there already */
itt = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
- e_cal_component_set_created (comp, &itt);
- e_cal_component_set_last_modified (comp, &itt);
+
+ if (!icalcomponent_get_first_property (icalcomp, ICAL_CREATED_PROPERTY)) {
+ /* Update both when CREATED is missing, to make sure the LAST-MODIFIED
+ is not before CREATED */
+ e_cal_component_set_created (comp, &itt);
+ e_cal_component_set_last_modified (comp, &itt);
+ } else if (!icalcomponent_get_first_property (icalcomp, ICAL_LASTMODIFIED_PROPERTY)) {
+ e_cal_component_set_last_modified (comp, &itt);
+ }
if (*offline_flag == E_CACHE_OFFLINE_UNKNOWN) {
if (e_backend_get_online (E_BACKEND (meta_backend)) &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]