Fix bug 2231: reverse_sync in fsmongo obtains file timestamp with UTC timezone instea... 40/13240/1 v13.0.2
authorGabriel Cuba <gcuba@whitestack.com>
Tue, 4 Apr 2023 06:57:17 +0000 (01:57 -0500)
committeraticig <gulsum.atici@canonical.com>
Wed, 19 Apr 2023 14:14:41 +0000 (15:14 +0100)
that filesystem and mongodb timestamps are correctly compared

Change-Id: I0056026704a624329aae1ae52a45143d12f6dfdd
Signed-off-by: Gabriel Cuba <gcuba@whitestack.com>
(cherry picked from commit 09496abf441b0f3730f0288df161da1ca004be69)

osm_common/fsmongo.py
releasenotes/notes/Fix_bug_2231-3b2a0cf186a460ce.yaml [new file with mode: 0644]

index 2b67cf3..b0fe4a1 100644 (file)
@@ -602,7 +602,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 (file)
index 0000000..6f27b8f
--- /dev/null
@@ -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