Fix bug 1069: Add default value for fsmongo.GridByteStream.file_type 03/9103/1
authorDavid Garcia <david.garcia@canonical.com>
Wed, 20 May 2020 10:09:37 +0000 (12:09 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 17 Jun 2020 13:46:49 +0000 (13:46 +0000)
Change-Id: Icf2b6c76a77526f118facd2053bd8dac33730415
Signed-off-by: David Garcia <david.garcia@canonical.com>
osm_common/fsmongo.py

index cd7f7f0..3c68a5f 100644 (file)
@@ -35,6 +35,7 @@ class GridByteStream(BytesIO):
         self.filename = filename
         self.fs = fs
         self.mode = mode
+        self.file_type = "file"  # Set "file" as default file_type
 
         self.__initialize__()
 
@@ -110,6 +111,7 @@ class GridStringStream(StringIO):
         self.filename = filename
         self.fs = fs
         self.mode = mode
+        self.file_type = "file"  # Set "file" as default file_type
 
         self.__initialize__()
 
@@ -200,7 +202,7 @@ class FsMongo(FsBase):
         for directory in dir_cursor:
             os.makedirs(self.path + directory.filename, exist_ok=True)
 
-        file_cursor = self.fs.find({"metadata.type": {"$elemMatch": ["file", "sym"]}}, no_cursor_timeout=True)
+        file_cursor = self.fs.find({"metadata.type": {"$in": ["file", "sym"]}}, no_cursor_timeout=True)
 
         for writing_file in file_cursor:
             file_path = self.path + writing_file.filename
@@ -210,7 +212,7 @@ class FsMongo(FsBase):
             if "permissions" in writing_file.metadata:
                 if writing_file.metadata["type"] == "sym":
                     os.chmod(
-                        file_path, 
+                        file_path,
                         writing_file.metadata["permissions"] | stat.S_IFLNK
                     )
                 else: