hgext/largefiles/proto.py
changeset 25079 bee00e0c2e45
parent 21084 70252bdfd39c
child 25660 328739ea70c3
equal deleted inserted replaced
25078:e8348f1cc228 25079:bee00e0c2e45
    29     path = lfutil.storepath(repo, sha)
    29     path = lfutil.storepath(repo, sha)
    30     util.makedirs(os.path.dirname(path))
    30     util.makedirs(os.path.dirname(path))
    31     tmpfp = util.atomictempfile(path, createmode=repo.store.createmode)
    31     tmpfp = util.atomictempfile(path, createmode=repo.store.createmode)
    32 
    32 
    33     try:
    33     try:
    34         try:
    34         proto.getfile(tmpfp)
    35             proto.getfile(tmpfp)
    35         tmpfp._fp.seek(0)
    36             tmpfp._fp.seek(0)
    36         if sha != lfutil.hexsha1(tmpfp._fp):
    37             if sha != lfutil.hexsha1(tmpfp._fp):
    37             raise IOError(0, _('largefile contents do not match hash'))
    38                 raise IOError(0, _('largefile contents do not match hash'))
    38         tmpfp.close()
    39             tmpfp.close()
    39         lfutil.linktousercache(repo, sha)
    40             lfutil.linktousercache(repo, sha)
    40     except IOError, e:
    41         except IOError, e:
    41         repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') %
    42             repo.ui.warn(_('largefiles: failed to put %s into store: %s\n') %
    42                      (sha, e.strerror))
    43                          (sha, e.strerror))
    43         return wireproto.pushres(1)
    44             return wireproto.pushres(1)
       
    45     finally:
    44     finally:
    46         tmpfp.discard()
    45         tmpfp.discard()
    47 
    46 
    48     return wireproto.pushres(0)
    47     return wireproto.pushres(0)
    49 
    48