1
# Copyright 2008-2015 Canonical
2
# Copyright 2015 Chicharreros (https://launchpad.net/~chicharreros)
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU Affero General Public License as
6
# published by the Free Software Foundation, either version 3 of the
7
# License, or (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Affero General Public License for more details.
14
# You should have received a copy of the GNU Affero General Public License
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
# For further info, check http://launchpad.net/magicicada-server
19
"""Support for REST Resumable Uploads."""
23
CREATE TABLE resumable_upload (
24
upload_id uuid PRIMARY KEY NOT NULL,
25
owner_id integer NOT NULL REFERENCES StorageUserInfo ON DELETE CASCADE,
26
volume_path text NOT NULL,
29
when_started timestamp without time zone
30
default timezone('UTC'::text, now()) not null,
31
when_last_active timestamp without time zone
32
default timezone('UTC'::text, now()) not null,
33
status lifecycle_status default 'Live'::lifecycle_status not null,
34
storage_key uuid NOT NULL,
35
part_count bigint NOT NULL,
36
uploaded_bytes bigint NOT NULL,
38
magic_hash_context bytea,
43
COMMENT ON TABLE resumable_upload IS
44
'Tracks resumable upload that will result in a \
45
ContentBlob being created'
48
COMMENT ON COLUMN resumable_upload.upload_id IS
49
'Unique identifier for the upload attempt';
52
COMMENT ON COLUMN resumable_upload.owner_id IS
53
'The id of the owner of the file';
56
COMMENT ON COLUMN resumable_upload.volume_path IS
57
'The volume path for the file which will be created';
60
COMMENT ON COLUMN resumable_upload.size IS
61
'The size in bytes of the file being uploaded';
64
COMMENT ON COLUMN resumable_upload.when_started IS
65
'Timestamp when this upload started';
68
COMMENT ON COLUMN resumable_upload.when_last_active IS
69
'Timestamp for when the last chunk was created for this upload action';
72
COMMENT ON COLUMN resumable_upload.storage_key IS
73
'The objectName which will be created by this upload';
76
COMMENT ON COLUMN resumable_upload.part_count IS
77
'The number of parts uploaded so far';
80
COMMENT ON COLUMN resumable_upload.uploaded_bytes IS
81
'The number of bytes uploaded so far';
84
COMMENT ON COLUMN resumable_upload.hash_context IS
85
'The state of the resumable hasher';
88
COMMENT ON COLUMN resumable_upload.magic_hash_context IS
89
'The state of the resumable magic hasher';
92
COMMENT ON COLUMN resumable_upload.crc_context IS
93
'The state of the resumable compressor';
96
CREATE INDEX resumable_upload_owner_idx ON resumable_upload(owner_id);
102
"""Apply the patch."""