Fix bug 1069: Add default value for fsmongo.GridByteStream.file_type 41/8941/3 v7.1.0 v7.1.0rc2 v7.1.0rc3 v7.1.0rc4 v7.1.0rc5 v7.1.0rc6 v7.1.2 v7.1.3
authorDavid Garcia <david.garcia@canonical.com>
Wed, 20 May 2020 10:09:37 +0000 (12:09 +0200)
committerDavid Garcia <david.garcia@canonical.com>
Wed, 20 May 2020 10:17:30 +0000 (12:17 +0200)
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: