File tree 6 files changed +13
-18
lines changed
6 files changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,9 @@ def put(self, download: DescribeDownload):
16
16
session .add (download )
17
17
session .commit ()
18
18
19
- def get (self , job_id : str ) -> Optional [DescribeDownload ]:
19
+ def get (self , download_id : str ) -> Optional [DescribeDownload ]:
20
20
with self .session () as session :
21
- download = session .query (Download ).filter (Download .job_id == job_id ).first ()
21
+ download = session .query (Download ).filter (Download .download_id == download_id ).first ()
22
22
23
23
if download :
24
24
return DescribeDownload .from_orm (download )
@@ -45,13 +45,14 @@ def __init__(self, db_url: str):
45
45
self .record_manager = DownloadRecordManager (db_url = db_url )
46
46
self .queue = Queue ()
47
47
48
- def download_from_staging (self , job_id : str ):
48
+ def download_from_staging (self , job_id : str , redownload : bool ):
49
49
download_initiated_time = get_utc_timestamp ()
50
50
download_id = generate_uuid ()
51
51
download = DescribeDownload (
52
52
job_id = job_id ,
53
53
download_id = download_id ,
54
54
download_initiated_time = download_initiated_time ,
55
+ redownload = redownload ,
55
56
)
56
57
self .record_manager .put (download )
57
58
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 @@ -165,6 +165,7 @@ def _download_from_staging(self, job_id: str):
165
165
job_id = job_id ,
166
166
download_id = download_id ,
167
167
download_initiated_time = download_initiated_time ,
168
+ redownload = True ,
168
169
)
169
170
with self .db_session () as session :
170
171
download_record = Download (** download .dict ())
Original file line number Diff line number Diff line change @@ -394,16 +394,8 @@ def get(self):
394
394
395
395
396
396
class FilesDownloadHandler (ExtensionHandlerMixin , APIHandler ):
397
- # _job_files_manager = None
398
397
_download_from_staging = None
399
398
400
- # @property
401
- # def job_files_manager(self):
402
- # if not self._job_files_manager:
403
- # self._job_files_manager = self.settings.get("job_files_manager", None)
404
-
405
- # return self._job_files_manager
406
-
407
399
@property
408
400
def download_from_staging (self ):
409
401
if not self ._download_from_staging :
@@ -413,10 +405,9 @@ def download_from_staging(self):
413
405
414
406
@authenticated
415
407
async def get (self , job_id ):
416
- # redownload = self.get_query_argument("redownload", False)
408
+ redownload = self .get_query_argument ("redownload" , False )
417
409
try :
418
- # await self.job_files_manager.copy_from_staging(job_id=job_id, redownload=redownload)
419
- self .download_from_staging (job_id )
410
+ self .download_from_staging (job_id , redownload )
420
411
except Exception as e :
421
412
self .log .exception (e )
422
413
raise HTTPError (500 , str (e )) from e
Original file line number Diff line number Diff line change @@ -300,6 +300,7 @@ class DescribeDownload(BaseModel):
300
300
job_id : str
301
301
download_id : str
302
302
download_initiated_time : int
303
+ redownload : bool
303
304
304
305
class Config :
305
306
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