class ResumeCache(object):
CACHE_DIR = '.cache/arvados/arv-put'
- @classmethod
- def setup_user_cache(cls):
- return arv_cmd.make_home_conf_dir(cls.CACHE_DIR, 0o700)
-
def __init__(self, file_spec):
self.cache_file = open(file_spec, 'a+')
self._lock_file(self.cache_file)
md5.update(str(max(args.max_manifest_depth, -1)))
elif args.filename:
md5.update(args.filename)
- return os.path.join(cls.CACHE_DIR, md5.hexdigest())
+ return os.path.join(
+ arv_cmd.make_home_conf_dir(cls.CACHE_DIR, 0o700, 'raise'),
+ md5.hexdigest())
def _lock_file(self, fileobj):
try:
bytes_expected = expected_bytes_for(args.paths)
resume_cache = None
- try:
- if ResumeCache.setup_user_cache() is not None:
+ if args.resume:
+ try:
resume_cache = ResumeCache(ResumeCache.make_path(args))
- except (IOError, OSError):
- pass # Couldn't open cache directory/file. Continue without it.
- except ResumeCacheConflict:
- stdout.write(
- "arv-put: Another process is already uploading this data.\n")
- sys.exit(1)
+ except (IOError, OSError, ValueError):
+ pass # Couldn't open cache directory/file. Continue without it.
+ except ResumeCacheConflict:
+ print >>stderr, "\n".join([
+ "arv-put: Another process is already uploading this data.",
+ " Use --no-resume if this is really what you want."])
+ sys.exit(1)
if resume_cache is None:
writer = ArvPutCollectionWriter(resume_cache, reporter, bytes_expected)
else:
- if not args.resume:
- resume_cache.restart()
+ resume_cache.restart()
writer = ArvPutCollectionWriter.from_cache(
resume_cache, reporter, bytes_expected)