Beispiel #1
0
    def copy(self, meta, fresh_meta):
        sxcontroller = get_sxcontroller()
        metadata = get_metadata(self.src_vol, self.src_path)

        clean_meta = {
            'etag': metadata.get('etag', ''),
            'content-type': metadata.get('content-type', 'application/octet-stream'),
            'last-modified': datetime_to_http_iso(datetime.utcnow()),
        }

        if not fresh_meta:
            for key, value in meta:
                clean_meta[key] = value
        meta = clean_meta

        file_info = sxcontroller.getFile.json_call(
            self.src_vol, self.src_path
        )

        blocks = [obj.keys()[0] for obj in file_info['fileData']]
        size = file_info['fileSize']

        resp = sxcontroller.initializeFile.call(
            self.dst_vol, self.dst_path, size, blocks,
            encode_meta(meta)
        )
        token = resp.json()['uploadToken']

        sxcontroller.flushUploadedFile.call_on_node(resp.node_address, token)
Beispiel #2
0
    def copy(self, meta, fresh_meta):
        sxcontroller = get_sxcontroller()
        metadata = get_metadata(self.src_vol, self.src_path)

        clean_meta = {
            'etag':
            metadata.get('etag', ''),
            'content-type':
            metadata.get('content-type', 'application/octet-stream'),
            'last-modified':
            datetime_to_http_iso(datetime.utcnow()),
        }

        if not fresh_meta:
            for key, value in meta:
                clean_meta[key] = value
        meta = clean_meta

        file_info = sxcontroller.getFile.json_call(self.src_vol, self.src_path)

        blocks = [obj.keys()[0] for obj in file_info['fileData']]
        size = file_info['fileSize']

        resp = sxcontroller.initializeFile.call(self.dst_vol,
                                                self.dst_path, size, blocks,
                                                encode_meta(meta))
        token = resp.json()['uploadToken']

        sxcontroller.flushUploadedFile.call_on_node(resp.node_address, token)
Beispiel #3
0
    def save(self, new_meta):
        current_meta = get_metadata(self.vol_name, self.object_path)

        key = 'content-type'
        if key not in new_meta and key in current_meta:
            new_meta[key] = current_meta[key]

        sxcontroller = get_sxcontroller()
        file_info = sxcontroller.getFile.json_call(
            self.vol_name, self.object_path
        )

        blocks = [obj.keys()[0] for obj in file_info['fileData']]
        size = file_info['fileSize']

        # We create new file because this is the only way to alter
        # meta on sx file.
        resp = sxcontroller.initializeFile.call(
            self.vol_name, self.object_path, size, blocks,
            encode_meta(new_meta)
        )
        token = resp.json()['uploadToken']

        sxcontroller.flushUploadedFile.call_on_node(resp.node_address, token)