-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel3_refactor.py
More file actions
34 lines (30 loc) · 1.33 KB
/
level3_refactor.py
File metadata and controls
34 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class FileServer:
def __init__(self):
# TODO: initialize your data structure here
pass
def FILE_UPLOAD_AT(self, timestamp: int, file_name: str, size: int, ttl=None):
"""
Upload a file at a given timestamp.
If ttl is provided, the file expires at timestamp + ttl.
Raise RuntimeError if file already exists.
"""
# TODO: implement upload with ttl
def FILE_GET_AT(self, timestamp: int, file_name: str):
"""
Return size if file exists and is alive at given timestamp, else None.
"""
# TODO: implement get with ttl check
def FILE_COPY_AT(self, timestamp: int, source: str, dest: str):
"""
Copy the source file to a new destination at the given timestamp.
- The copied file uses the current timestamp as its upload time.
- The copied file inherits the same TTL duration as the source.
- Raise RuntimeError if the source file does not exist or is expired at the given timestamp.
- Overwrite the destination if it already exists.
"""
# TODO: implement copy with ttl
def FILE_SEARCH_AT(self, timestamp: int, prefix: str):
"""
Return up to 10 alive files starting with prefix, sorted by size desc, name asc.
"""
# TODO: implement search with ttl filter