def store_fileobject(self, fileobject, path, interrupt_event=None):
     self.logger.debug("meta cache store_fileobject %s", path)
     data_len = file_util.get_file_size_in_bytes(fileobject)
     if not self.entries.exists(path):
         self.entries.write(path, Entry())
     entry = self.entries.get_value(path)
     entry.set_is_file()
     entry.size = data_len
     entry.set_modified()
     self.entries.write(path, entry)
     try:
         self._acquire_uploading_lock()
         ret = self.store.store_fileobject(fileobject, path, interrupt_event)
     except:
         # delete entry
         self.entries.delete(path)
         raise
     finally:
         self._release_uploading_lock()
         fileobject.close()
     entry = self.entries.get_value(path)
     entry.set_is_file()
     entry.size = data_len
     entry.set_modified()
     self._add_to_parent_dir_listing(path)
     self.entries.write(path, entry)
     return ret
 def store_file(self, path_to_file, dest_dir="/", remote_file_name = None, interrupt_event=None):
     if dest_dir == "/":
         dest_dir = ""
     if not remote_file_name:
         remote_file_name = os.path.basename(path_to_file)
     data_len = file_util.get_file_size_in_bytes(path_to_file)
     path = dest_dir + "/" + remote_file_name
     self.logger.debug("meta cache store_file %s", dest_dir + "/" + remote_file_name)
     if not self.entries.exists(path):
         self.entries.write(path, Entry())
     entry = self.entries.get_value(path)
     entry.set_is_file()
     entry.size = data_len
     entry.set_modified()
     self.entries.write(path, entry)
     self.logger.debug("meta cache store_file %s", path)
     try:
         self._acquire_uploading_lock()
         ret = self.store.store_file(path_to_file, dest_dir, remote_file_name, interrupt_event)
     except:
         # delete entry
         self.entries.delete(path)
         raise
     finally:
         self._release_uploading_lock()
     entry = self.entries.get_value(path)
     entry.set_is_file()
     entry.size = data_len
     entry.set_modified()
     self.entries.write(path, entry)
     self._add_to_parent_dir_listing(path)
     return ret
Beispiel #3
0
 def flush(self, path, fh):
     self.logger.debug("flush %s - fh: %s", path, fh)
     if path in self.temp_file: #after writes
         if self.store.get_free_space() < file_util.get_file_size_in_bytes(self.temp_file[path]):
             self._release(path, 0)
             return FuseOSError(ENOSPC)
         try:
             self.store.store_fileobject(self.temp_file[path], path)
         except NoSuchFilesytemObjectError:
             raise FuseOSError(ENOENT)
         except StoreAccessError:
             raise FuseOSError(EIO)
         except StoreAutorizationError:
             raise FuseOSError(EACCES) #keine Berechtigung
     return 0
Beispiel #4
0
 def flush(self, path, fh):
     self.logger.debug("flush %s - fh: %s", path, fh)
     if path in self.temp_file:  #after writes
         if self.store.get_free_space() < file_util.get_file_size_in_bytes(
                 self.temp_file[path]):
             self._release(path, 0)
             return FuseOSError(ENOSPC)
         try:
             self.store.store_fileobject(self.temp_file[path], path)
         except NoSuchFilesytemObjectError:
             raise FuseOSError(ENOENT)
         except StoreAccessError:
             raise FuseOSError(EIO)
         except StoreAutorizationError:
             raise FuseOSError(EACCES)  #keine Berechtigung
     return 0
Beispiel #5
0
 def store_fileobject(self, fileobject, path, interrupt_event=None):
     size = file_util.get_file_size_in_bytes(fileobject)
     self.logger.info("Storing file object of size %s to %s", size, path)
     with open(self.root + path, 'w') as f:
         f.write(fileobject.read())
     return os.path.getmtime(self.root + path)
 def store_fileobject(self, fileobject, path, interrupt_event=None):
     size = file_util.get_file_size_in_bytes(fileobject)
     self.logger.info("Storing file object of size %s to %s", size, path)
     with open(self.root+path, 'w') as f:
         f.write(fileobject.read())
     return os.path.getmtime(self.root+path)