paramiko getting offset 0
John Arbash Meinel
john at arbash-meinel.com
Tue Jul 31 23:37:28 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
I just spent some time on IRC debugging a knit corruption issue.
Basically, it seems like when we went to append to a .kndx it wrote to the
beginning of a file, rather than writing to the end.
I'm guessing that for some (very weird) reason the stat value returned length
0, or something else.
I was just thinking that for .kndx files, we know that they aren't 0 length if
we have succeeded in reading the header.
So if we go to append and it claims to be 0-bytes long, we know that it is wrong.
Do you think there is a reasonable way to either tell paramiko this, or detect
it somehow so that we can abort the append rather than writing to the wrong
I see that BufferedFile has a ._size attribute.
So, theoretically in bzrlib.transport.sftp we could do:
fout = self._get_sftp().file(path, 'ab')
if mode is not None:
result = fout.tell()
if result == 0:
raise errors.BadMojo('we are appending to a file that claims it should
be empty, but we know it is not')
I don't think we should specifically do that, but I know that at the moment, we
use 'put_non_atomic' if we know that the file doesn't exist, and only use
'append' if we have already read it.
Maybe a 'file_not_empty' flag to append?
Having a .kndx file claim to be 0 length means that we corrupt it. So I would
like to try to be cautious.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar