From: Brett Smith Date: Fri, 23 May 2014 20:46:49 +0000 (-0400) Subject: 2752: Add ResumeCache.restart(). X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/fd2809f4c0c8d20f76e8f360673990879fbe3ad9?ds=sidebyside 2752: Add ResumeCache.restart(). This will make it easier for the user to bypass the cache. --- diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py index 37974c0945..439504786e 100644 --- a/sdk/python/arvados/commands/put.py +++ b/sdk/python/arvados/commands/put.py @@ -198,6 +198,10 @@ class ResumeCache(object): raise self.close() + def restart(self): + self.destroy() + self.__init__(self.filename) + class ArvPutCollectionWriter(arvados.ResumableCollectionWriter): def __init__(self, cache=None, reporter=None, bytes_expected=None): diff --git a/sdk/python/tests/test_arv-put.py b/sdk/python/tests/test_arv-put.py index e765482106..a98eaa6a5e 100644 --- a/sdk/python/tests/test_arv-put.py +++ b/sdk/python/tests/test_arv-put.py @@ -170,6 +170,15 @@ class ArvadosPutResumeCacheTest(ArvadosBaseTestCase): if os.path.exists(cachefile.name): os.unlink(cachefile.name) + def test_restart_cache(self): + path = os.path.join(self.make_tmpdir(), 'cache') + cache = arv_put.ResumeCache(path) + cache.save('test') + cache.restart() + self.assertRaises(ValueError, cache.load) + self.assertRaises(arv_put.ResumeCacheConflict, + arv_put.ResumeCache, path) + class ArvadosPutCollectionWriterTest(ArvadosKeepLocalStoreTestCase): def setUp(self):