From: Gabriel Cuba Date: Tue, 4 Apr 2023 06:57:17 +0000 (-0500) Subject: Fix bug 2231: reverse_sync in fsmongo obtains file timestamp with UTC timezone instea... X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F41%2F13241%2F1;p=osm%2Fcommon.git 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 (cherry picked from commit 09496abf441b0f3730f0288df161da1ca004be69) --- diff --git a/osm_common/fsmongo.py b/osm_common/fsmongo.py index 21a5d67..44e7eef 100644 --- a/osm_common/fsmongo.py +++ b/osm_common/fsmongo.py @@ -541,7 +541,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