File tree Expand file tree Collapse file tree 6 files changed +13
-18
lines changed Expand file tree Collapse file tree 6 files changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ def put(self, download: DescribeDownload):
17
17
session .add (download )
18
18
session .commit ()
19
19
20
- def get (self , job_id : str ) -> Optional [DescribeDownload ]:
20
+ def get (self , download_id : str ) -> Optional [DescribeDownload ]:
21
21
with self .session () as session :
22
- download = session .query (Download ).filter (Download .job_id == job_id ).first ()
22
+ download = session .query (Download ).filter (Download .download_id == download_id ).first ()
23
23
24
24
if download :
25
25
return DescribeDownload .from_orm (download )
@@ -46,13 +46,14 @@ def __init__(self, db_url: str):
46
46
self .record_manager = DownloadRecordManager (db_url = db_url )
47
47
self .queue = Queue ()
48
48
49
- def download_from_staging (self , job_id : str ):
49
+ def download_from_staging (self , job_id : str , redownload : bool ):
50
50
download_initiated_time = get_utc_timestamp ()
51
51
download_id = generate_uuid ()
52
52
download = DescribeDownload (
53
53
job_id = job_id ,
54
54
download_id = download_id ,
55
55
download_initiated_time = download_initiated_time ,
56
+ redownload = redownload ,
56
57
)
57
58
self .record_manager .put (download )
58
59
self .queue .put (download )
Original file line number Diff line number Diff line change @@ -23,11 +23,11 @@ def __init__(
23
23
async def process_download_queue (self ):
24
24
while not self .download_manager .queue .empty ():
25
25
download = self .download_manager .queue .get ()
26
- cache = self .download_manager .record_manager .get (download .job_id )
27
- if not cache or not download :
26
+ download_record = self .download_manager .record_manager .get (download .download_id )
27
+ if not download_record :
28
28
continue
29
- await self .job_files_manager .copy_from_staging (cache .job_id )
30
- self .download_manager .record_manager . delete_download (cache .download_id )
29
+ await self .job_files_manager .copy_from_staging (download .job_id , download . redownload )
30
+ self .download_manager .delete_download (download .download_id )
31
31
32
32
async def start (self ):
33
33
self .download_manager .populate_queue ()
Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ def _download_from_staging(self, job_id: str):
163
163
job_id = job_id ,
164
164
download_id = download_id ,
165
165
download_initiated_time = download_initiated_time ,
166
+ redownload = True ,
166
167
)
167
168
with self .db_session () as session :
168
169
download_record = Download (** download .dict ())
Original file line number Diff line number Diff line change @@ -395,16 +395,8 @@ def get(self):
395
395
396
396
397
397
class FilesDownloadHandler (ExtensionHandlerMixin , APIHandler ):
398
- # _job_files_manager = None
399
398
_download_from_staging = None
400
399
401
- # @property
402
- # def job_files_manager(self):
403
- # if not self._job_files_manager:
404
- # self._job_files_manager = self.settings.get("job_files_manager", None)
405
-
406
- # return self._job_files_manager
407
-
408
400
@property
409
401
def download_from_staging (self ):
410
402
if not self ._download_from_staging :
@@ -414,10 +406,9 @@ def download_from_staging(self):
414
406
415
407
@authenticated
416
408
async def get (self , job_id ):
417
- # redownload = self.get_query_argument("redownload", False)
409
+ redownload = self .get_query_argument ("redownload" , False )
418
410
try :
419
- # await self.job_files_manager.copy_from_staging(job_id=job_id, redownload=redownload)
420
- self .download_from_staging (job_id )
411
+ self .download_from_staging (job_id , redownload )
421
412
except Exception as e :
422
413
self .log .exception (e )
423
414
raise HTTPError (500 , str (e )) from e
Original file line number Diff line number Diff line change @@ -301,6 +301,7 @@ class DescribeDownload(BaseModel):
301
301
job_id : str
302
302
download_id : str
303
303
download_initiated_time : int
304
+ redownload : bool
304
305
305
306
class Config :
306
307
orm_mode = True
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ class Download(Base):
116
116
job_id = Column (String (36 ), primary_key = True )
117
117
download_id = Column (String (36 ), primary_key = True )
118
118
download_initiated_time = Column (Integer )
119
+ redownload = Column (Boolean , default = False )
119
120
120
121
121
122
def create_tables (db_url , drop_tables = False ):
You can’t perform that action at this time.
0 commit comments