only look for images in available volumes
This commit is contained in:
parent
86cccee265
commit
662c8569fb
1 changed files with 42 additions and 38 deletions
|
@ -667,6 +667,7 @@ class Client(object):
|
||||||
if not self.user:
|
if not self.user:
|
||||||
print("you need to login")
|
print("you need to login")
|
||||||
return
|
return
|
||||||
|
|
||||||
documents = []
|
documents = []
|
||||||
if args:
|
if args:
|
||||||
data = []
|
data = []
|
||||||
|
@ -694,6 +695,9 @@ class Client(object):
|
||||||
files = []
|
files = []
|
||||||
info = []
|
info = []
|
||||||
else:
|
else:
|
||||||
|
if not self.active_volumes():
|
||||||
|
print("no volumes found, mount volumes and run again")
|
||||||
|
return
|
||||||
# send empty list to get updated list of requested info/files/data
|
# send empty list to get updated list of requested info/files/data
|
||||||
post = {'info': {}}
|
post = {'info': {}}
|
||||||
r = self.api.update(post)
|
r = self.api.update(post)
|
||||||
|
@ -784,27 +788,28 @@ class Client(object):
|
||||||
print(r)
|
print(r)
|
||||||
|
|
||||||
def _get_documents(self):
|
def _get_documents(self):
|
||||||
|
files = []
|
||||||
|
for volume in self.active_volumes():
|
||||||
query = {
|
query = {
|
||||||
|
'conditions': [
|
||||||
|
{'key': 'list', 'value': volume, 'operator': '=='},
|
||||||
|
{
|
||||||
'conditions': [
|
'conditions': [
|
||||||
{'key': 'filename', 'operator': '', 'value': value}
|
{'key': 'filename', 'operator': '', 'value': value}
|
||||||
for value in DOCUMENT_FORMATS
|
for value in DOCUMENT_FORMATS
|
||||||
],
|
],
|
||||||
'operator': '|'
|
'operator': '|'
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
'operator': '&'
|
||||||
|
}
|
||||||
n = self.api.findMedia({'query': query})['data']['items']
|
n = self.api.findMedia({'query': query})['data']['items']
|
||||||
if n:
|
if n:
|
||||||
o = 0
|
o = 0
|
||||||
chunk = 5000
|
chunk = 5000
|
||||||
files = []
|
|
||||||
while o < n:
|
while o < n:
|
||||||
files += self.api.findMedia({
|
files += self.api.findMedia({
|
||||||
'query': {
|
'query': query,
|
||||||
'conditions': [
|
|
||||||
{'key': 'filename', 'operator': '', 'value': value}
|
|
||||||
for value in DOCUMENT_FORMATS
|
|
||||||
],
|
|
||||||
'operator': '|'
|
|
||||||
},
|
|
||||||
'keys': ['item', 'id', 'extension'],
|
'keys': ['item', 'id', 'extension'],
|
||||||
'range': [o, o+chunk]
|
'range': [o, o+chunk]
|
||||||
})['data']['items']
|
})['data']['items']
|
||||||
|
@ -824,8 +829,6 @@ class Client(object):
|
||||||
'range': [0, chunk]
|
'range': [0, chunk]
|
||||||
})['data']['items']
|
})['data']['items']
|
||||||
o += chunk
|
o += chunk
|
||||||
else:
|
|
||||||
d = []
|
|
||||||
available = set(f['oshash']
|
available = set(f['oshash']
|
||||||
for f in d if f['extension'] in DOCUMENT_FORMATS)
|
for f in d if f['extension'] in DOCUMENT_FORMATS)
|
||||||
missing = [(f['id'], f['item']) for f in files
|
missing = [(f['id'], f['item']) for f in files
|
||||||
|
@ -847,7 +850,8 @@ class Client(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _add_document(self, f, item=None):
|
def _add_document(self, f, item=None):
|
||||||
if f.split('.')[-1] not in DOCUMENT_FORMATS:
|
if f.split('.')[-1].lower() not in DOCUMENT_FORMATS:
|
||||||
|
print('skip, not a document', f)
|
||||||
return False
|
return False
|
||||||
oshash = ox.oshash(f)
|
oshash = ox.oshash(f)
|
||||||
did = self.find_document(oshash)
|
did = self.find_document(oshash)
|
||||||
|
|
Loading…
Reference in a new issue