예제 #1
0
    def _ProcessPending():
        while len(inflight) < _INFLIGHT_LIMIT and len(pending) > 0:
            photo = pending.popleft()
            #if options.options.copy_files and photo.new_assets == 'copied':
            #  continue
            with util.Barrier(partial(_OnProcessed, photo,
                                      _ProcessPending)) as b:
                for ak, nak in [(fmt % photo.photo_id, nfmt % photo.photo_id) \
                                  for fmt, nfmt in (('%s', '%s.o'),
                                                    ('%s_f', '%s.f'),
                                                    ('%s_m', '%s.m'),
                                                    ('%s_t', '%s.t'))]:
                    assert ak not in inflight, ak
                    inflight.add(ak)
                    finish_cb = b.Callback()
                    with util.MonoBarrier(partial(_OnPhotoGet, ak, nak,
                                                  finish_cb),
                                          on_exception=partial(
                                              _OnErrorGet, ak,
                                              finish_cb)) as get_b:
                        obj_store.Get(ak, get_b.Callback())

        if len(pending) == 0 and len(inflight) == 0:
            if last_key and count < max_count:
                Photo.Scan(client,
                           col_names=None,
                           limit=_SCAN_LIMIT,
                           excl_start_key=last_key,
                           callback=partial(_OnScan, final_cb, client, count))
            else:
                logging.info('finished rename of %d photos' % count)
                final_cb()
예제 #2
0
def _Start(callback):
    """Scans the entire photo table, renaming existing photo asset files
  from old names to new. If deletion is specified, removes old file. If
  neither deletion nor rename is specified, simply logs rename intention
  and delete intention.
  """
    if options.options.REALLY_DELETE_OLD:
        assert options.options.verify_files, 'must specify --verify_files to delete'
    client = DBClient.Instance()
    Photo.Scan(client,
               col_names=None,
               limit=_SCAN_LIMIT,
               excl_start_key=None,
               callback=partial(_OnScan, callback, client, 0))