def test_profile_get_repo_files(annex_path, new_dataset): ds_id = os.path.basename(new_dataset.path) ds = Dataset(str(annex_path.join(ds_id))) for each in range(5000): filename = 'file-{}'.format(each) path = os.path.join(new_dataset.path, filename) with open(path, 'a'): os.utime(path) # Add all generated files ds.add('.') # Profile get_repo_files by itself with open('{}.prof'.format(__name__), 'w+b') as fd: vmprof.enable(fd.fileno()) for n in range(1): get_repo_files(ds) vmprof.disable()
def on_delete(self, req, resp, dataset, snapshot, annex_key): """Delete an existing annex_object on a dataset""" if annex_key: dataset_path = self.store.get_dataset_path(dataset) files = get_repo_files(dataset_path, snapshot) try: file = next(f for f in files if annex_key == f.get('key')) except StopIteration: resp.media = {'error': 'file does not exist'} resp.status = falcon.HTTP_BAD_REQUEST urls = file.get('urls') gevent.spawn(remove_file_remotes, urls) gevent.spawn(remove_annex_object, dataset_path, annex_key) else: resp.media = {'error': 'annex-key is missing'} resp.status = falcon.HTTP_NOT_FOUND
def get_files(store, dataset, branch=None): """Get the working tree, optionally a branch tree.""" ds = store.get_dataset(dataset) return get_repo_files(ds, branch)