1
# Copyright 2008-2015 Canonical
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as
5
# published by the Free Software Foundation, either version 3 of the
6
# License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
# For further info, check http://launchpad.net/filesync-server
18
"""Support for REST Resumable Uploads."""
22
CREATE TABLE resumable_upload (
23
upload_id uuid PRIMARY KEY NOT NULL,
24
owner_id integer NOT NULL REFERENCES StorageUserInfo ON DELETE CASCADE,
25
volume_path text NOT NULL,
28
when_started timestamp without time zone
29
default timezone('UTC'::text, now()) not null,
30
when_last_active timestamp without time zone
31
default timezone('UTC'::text, now()) not null,
32
status lifecycle_status default 'Live'::lifecycle_status not null,
33
multipart_id bytea 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.multipart_id IS
73
'The upload_id returned by S3';
76
COMMENT ON COLUMN resumable_upload.storage_key IS
77
'The S3 objectName which will be created by this upload';
80
COMMENT ON COLUMN resumable_upload.part_count IS
81
'The number of parts uploaded so far';
84
COMMENT ON COLUMN resumable_upload.uploaded_bytes IS
85
'The number of bytes uploaded so far';
88
COMMENT ON COLUMN resumable_upload.hash_context IS
89
'The state of the resumable hasher';
92
COMMENT ON COLUMN resumable_upload.magic_hash_context IS
93
'The state of the resumable magic hasher';
96
COMMENT ON COLUMN resumable_upload.crc_context IS
97
'The state of the resumable compressor';
100
GRANT SELECT,INSERT,DELETE,UPDATE
101
ON TABLE resumable_upload TO storage, webapp;
104
CREATE INDEX resumable_upload_owner_idx ON resumable_upload(owner_id);
110
"""Apply the patch."""