Fix bug 2231: reverse_sync in fsmongo obtains file timestamp with UTC timezone instea... 41/13141/1
authorGabriel Cuba <gcuba@whitestack.com>
Tue, 4 Apr 2023 06:57:17 +0000 (01:57 -0500)
committerGabriel Cuba <gcuba@whitestack.com>
Tue, 4 Apr 2023 06:57:17 +0000 (01:57 -0500)
that filesystem and mongodb timestamps are correctly compared

Change-Id: I0056026704a624329aae1ae52a45143d12f6dfdd
Signed-off-by: Gabriel Cuba <gcuba@whitestack.com>
osm_common/fsmongo.py
releasenotes/notes/Fix_bug_2231-3b2a0cf186a460ce.yaml [new file with mode: 0644]

index f99267f..4f4e5eb 100644 (file)
@@ -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 (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