mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
refresh for PendingInteract delete to avoid race condition, #217
This commit is contained in:
parent
34a1fe9e8e
commit
ca5b00a373
@ -103,7 +103,7 @@ class PendingInteract:
|
|||||||
def delete_item(self):
|
def delete_item(self):
|
||||||
"""delete single item from pending"""
|
"""delete single item from pending"""
|
||||||
path = f"ta_download/_doc/{self.video_id}"
|
path = f"ta_download/_doc/{self.video_id}"
|
||||||
_, _ = ElasticWrap(path).delete()
|
_, _ = ElasticWrap(path).delete(refresh=True)
|
||||||
|
|
||||||
def delete_by_status(self):
|
def delete_by_status(self):
|
||||||
"""delete all matching item by status"""
|
"""delete all matching item by status"""
|
||||||
|
@ -75,8 +75,10 @@ class ElasticWrap:
|
|||||||
|
|
||||||
return response.json(), response.status_code
|
return response.json(), response.status_code
|
||||||
|
|
||||||
def delete(self, data=False):
|
def delete(self, data=False, refresh=False):
|
||||||
"""delete document from es"""
|
"""delete document from es"""
|
||||||
|
if refresh:
|
||||||
|
self.url = f"{self.url}/?refresh=true"
|
||||||
if data:
|
if data:
|
||||||
response = requests.delete(self.url, json=data, auth=self.auth)
|
response = requests.delete(self.url, json=data, auth=self.auth)
|
||||||
else:
|
else:
|
||||||
|
@ -86,7 +86,7 @@ class YouTubeItem:
|
|||||||
def del_in_es(self):
|
def del_in_es(self):
|
||||||
"""delete item from elastic search"""
|
"""delete item from elastic search"""
|
||||||
print(f"{self.youtube_id}: delete from es")
|
print(f"{self.youtube_id}: delete from es")
|
||||||
_, _ = ElasticWrap(self.es_path).delete()
|
_, _ = ElasticWrap(self.es_path).delete(refresh=True)
|
||||||
|
|
||||||
|
|
||||||
class Pagination:
|
class Pagination:
|
||||||
|
Loading…
Reference in New Issue
Block a user