From c9d036f475401800237e66548b764726369d60fb Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 3 Dec 2011 08:14:17 -0800 Subject: [PATCH] index: bigger comment on ExistingFileSchemas Change-Id: Id9511ea0f516306038f74e9223e867230291fe1e --- lib/go/camli/search/search.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/go/camli/search/search.go b/lib/go/camli/search/search.go index 54a242815..7f3d2b692 100644 --- a/lib/go/camli/search/search.go +++ b/lib/go/camli/search/search.go @@ -143,14 +143,24 @@ type Index interface { // os.ENOENT should be returned if the blob isn't known GetBlobMimeType(blob *blobref.BlobRef) (mime string, size int64, err os.Error) - // ExistingFileSchemas returns 0 or more blobrefs of file - // schema blobs that represent the bytes of a file given in - // bytesRef. The file schema blobs returned are not - // guaranteed to reference chunks that still exist on the - // blobservers, though. It's purely a hint for clients to - // avoid uploads if possible. Before re-using any returned - // blobref they should be checked. - ExistingFileSchemas(bytesRef *blobref.BlobRef) ([]*blobref.BlobRef, os.Error) + // ExistingFileSchemas returns 0 or more blobrefs of "bytes" + // (TODO(bradfitz): or file?) schema blobs that represent the + // bytes of a file given in bytesRef. The file schema blobs + // returned are not guaranteed to reference chunks that still + // exist on the blobservers, though. It's purely a hint for + // clients to avoid uploads if possible. Before re-using any + // returned blobref they should be checked. + // + // Use case: a user drag & drops a large file onto their + // browser to upload. (imagine that "large" means anything + // larger than a blobserver's max blob size) JavaScript can + // first SHA-1 the large file locally, then send the + // wholeFileRef to this call and see if they'd previously + // uploaded the same file in the past. If so, the upload + // can be avoided if at least one of the returned schemaRefs + // can be validated (with a validating HEAD request) to still + // all exist on the blob server. + ExistingFileSchemas(wholeFileRef *blobref.BlobRef) (schemaRefs []*blobref.BlobRef, os.Error) GetFileInfo(fileRef *blobref.BlobRef) (*FileInfo, os.Error)