From 09496abf441b0f3730f0288df161da1ca004be69 Mon Sep 17 00:00:00 2001 From: Gabriel Cuba Date: Tue, 4 Apr 2023 01:57:17 -0500 Subject: [PATCH] Fix bug 2231: reverse_sync in fsmongo obtains file timestamp with UTC timezone instead of local timezone, so that filesystem and mongodb timestamps are correctly compared Change-Id: I0056026704a624329aae1ae52a45143d12f6dfdd Signed-off-by: Gabriel Cuba --- osm_common/fsmongo.py | 4 +++- .../notes/Fix_bug_2231-3b2a0cf186a460ce.yaml | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/Fix_bug_2231-3b2a0cf186a460ce.yaml diff --git a/osm_common/fsmongo.py b/osm_common/fsmongo.py index f99267f..4f4e5eb 100644 --- a/osm_common/fsmongo.py +++ b/osm_common/fsmongo.py @@ -601,7 +601,9 @@ class FsMongo(FsBase): # convert to relative path rel_filename = os.path.relpath(member["filename"], self.path) - last_modified_date = datetime.datetime.fromtimestamp( + # get timestamp in UTC because mongo stores upload date in UTC: + # https://www.mongodb.com/docs/v4.0/tutorial/model-time-data/#overview + last_modified_date = datetime.datetime.utcfromtimestamp( os.path.getmtime(member["filename"]) ) diff --git a/releasenotes/notes/Fix_bug_2231-3b2a0cf186a460ce.yaml b/releasenotes/notes/Fix_bug_2231-3b2a0cf186a460ce.yaml new file mode 100644 index 0000000..6f27b8f --- /dev/null +++ b/releasenotes/notes/Fix_bug_2231-3b2a0cf186a460ce.yaml @@ -0,0 +1,21 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Fixing bug 2231 - reverse_sync in fsmongo obtains file timestamp with UTC timezone instead of local timezone, so + that filesystem and mongodb timestamps are correctly compared \ No newline at end of file -- 2.17.1