add sha1 to db, set rightslevel if set in config
This commit is contained in:
parent
c442cf4086
commit
d0bf256c27
1 changed files with 26 additions and 2 deletions
|
@ -120,6 +120,14 @@ class Client(object):
|
||||||
for i in db:
|
for i in db:
|
||||||
c.execute(i)
|
c.execute(i)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
if int(self.get('version', 0)) < 3:
|
||||||
|
self.set('version', 3)
|
||||||
|
db = [
|
||||||
|
'''ALTER TABLE file add sha1 varchar(42)'''
|
||||||
|
]
|
||||||
|
for i in db:
|
||||||
|
c.execute(i)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
def _conn(self):
|
def _conn(self):
|
||||||
db_conn = os.path.expanduser(self._config['cache'])
|
db_conn = os.path.expanduser(self._config['cache'])
|
||||||
|
@ -216,10 +224,12 @@ class Client(object):
|
||||||
info = utils.avinfo(path)
|
info = utils.avinfo(path)
|
||||||
if info['size'] > 0:
|
if info['size'] > 0:
|
||||||
oshash = info['oshash']
|
oshash = info['oshash']
|
||||||
|
sha1 = None
|
||||||
deleted = -1
|
deleted = -1
|
||||||
t = (path, oshash, stat.st_atime, stat.st_ctime, stat.st_mtime,
|
t = (path, oshash, stat.st_atime, stat.st_ctime, stat.st_mtime,
|
||||||
stat.st_size, json.dumps(info), created, modified, deleted)
|
stat.st_size, json.dumps(info), created, modified, deleted, sha1)
|
||||||
c.execute(u'INSERT OR REPLACE INTO file values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', t)
|
c.execute(u'INSERT OR REPLACE INTO file values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||||
|
t)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
else:
|
else:
|
||||||
print info
|
print info
|
||||||
|
@ -501,6 +511,20 @@ class Client(object):
|
||||||
if not self.signin():
|
if not self.signin():
|
||||||
print "failed to login again"
|
print "failed to login again"
|
||||||
return
|
return
|
||||||
|
if 'rightsLevel' in self._config:
|
||||||
|
r = self.api.find({'query': {
|
||||||
|
'conditions': [
|
||||||
|
{'key': 'oshash', 'value': oshash, 'operator': '=='}
|
||||||
|
],
|
||||||
|
'keys': ['id'],
|
||||||
|
'range': [0, 1]
|
||||||
|
}})
|
||||||
|
if r['data']['items']:
|
||||||
|
item = r['data']['items'][0]['id']
|
||||||
|
r = self.api.edit({
|
||||||
|
'item': item,
|
||||||
|
'rightsLevel': self._config['rightsLevel']
|
||||||
|
})
|
||||||
break
|
break
|
||||||
|
|
||||||
def files(self, prefix):
|
def files(self, prefix):
|
||||||
|
|
Loading…
Reference in a new issue