use db to find possible paths for oshash

This commit is contained in:
j 2011-12-31 16:44:04 +05:30
parent b6c83219b4
commit f9970fdcea

View file

@ -310,26 +310,6 @@ class Client(object):
return return
conn, c = self._conn() conn, c = self._conn()
volumes = {}
for name in self._config['volumes']:
path = self._config['volumes'][name]
path = os.path.normpath(path)
volumes[name] = {}
volumes[name]['path'] = path
if os.path.exists(path):
volumes[name]['available'] = True
else:
volumes[name]['available'] = False
for name in volumes:
if volumes[name]['available']:
prefix = volumes[name]['path']
files = self.files(prefix)
filenames = {}
for f in files['files']:
filenames[f['oshash']] = f['path']
#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)
@ -337,22 +317,21 @@ class Client(object):
if r['data']['file']: if r['data']['file']:
print 'uploading %s files' % len(r['data']['file']) print 'uploading %s files' % len(r['data']['file'])
for oshash in r['data']['file']: for oshash in r['data']['file']:
if oshash in filenames: for path in self.path(oshash):
filename = filenames[oshash] if os.path.exists(path):
self.api.uploadData(os.path.join(prefix, filename), oshash) self.api.uploadData(path, oshash)
if r['data']['data']: if r['data']['data']:
print 'encoding and uploading %s videos' % len(r['data']['data']) print 'encoding and uploading %s videos' % len(r['data']['data'])
for oshash in r['data']['data']: for oshash in r['data']['data']:
data = {} data = {}
if oshash in filenames: for path in self.path(oshash):
filename = filenames[oshash] if os.path.exists(path):
info = files['info'][oshash] info = self.info(oshash)
if not self.api.uploadVideo(os.path.join(prefix, filename), if not self.api.uploadVideo(path, data, self.profile, info):
data, self.profile, info): if not self.signin():
if not self.signin(): print "failed to login again"
print "failed to login again" return
return
def files(self, prefix): def files(self, prefix):
conn, c = self._conn() conn, c = self._conn()