def open(self, filepath, flags): # TODO: Fail if does not exist and the mode/flags is read only. self.__log.debug("Building OpenedFile object for file being opened.") try: opened_file = OpenedFile.create_for_requested_filepath(filepath) except GdNotFoundError: self.__log.exception("Could not create handle for requested [%s] " "(open)." % (filepath)) raise FuseOSError(ENOENT) except: self.__log.exception("Could not create OpenedFile object for " "opened filepath [%s]." % (filepath)) raise FuseOSError(EIO) self.__log.debug("Created OpenedFile object [%s]." % (opened_file)) try: fh = OpenedManager.get_instance().add(opened_file) except: self.__log.exception("Could not register OpenedFile for opened " "file.") raise FuseOSError(EIO) self.__log.debug("File opened.") return fh
def create(self, raw_filepath, mode): """Create a new file. This always precedes a write.""" try: fh = OpenedManager.get_instance().get_new_handle() except: _logger.exception("Could not acquire file-handle for create of " "[%s]." % (raw_filepath)) raise FuseOSError(EIO) (entry, path, filename, mime_type) = self.__create(raw_filepath) try: opened_file = OpenedFile(entry.id, path, filename, not entry.is_visible, mime_type) except: _logger.exception("Could not create OpenedFile object for " "created file.") raise FuseOSError(EIO) try: OpenedManager.get_instance().add(opened_file, fh=fh) except: _logger.exception("Could not register OpenedFile for created " "file.") raise FuseOSError(EIO) return fh
def create(self, raw_filepath, mode): """Create a new file. This always precedes a write.""" self.__log.debug("Acquiring file-handle.") try: fh = OpenedManager.get_instance().get_new_handle() except: self.__log.exception("Could not acquire file-handle for create of " "[%s]." % (raw_filepath)) raise FuseOSError(EIO) (entry, path, filename, mime_type) = self.__create(raw_filepath) self.__log.debug("Building OpenedFile object for created file.") try: opened_file = OpenedFile(entry.id, path, filename, not entry.is_visible, mime_type) except: self.__log.exception("Could not create OpenedFile object for " "created file.") raise FuseOSError(EIO) self.__log.debug("Registering OpenedFile object with handle (%d), " "path [%s], and ID [%s]." % (fh, raw_filepath, entry.id)) try: OpenedManager.get_instance().add(opened_file, fh=fh) except: self.__log.exception("Could not register OpenedFile for created " "file.") raise FuseOSError(EIO) self.__log.debug("File created, opened, and completely registered.") return fh