Skip to content

Commit 9fdd9cd

Browse files
author
Keith Ball
committed
Report error when blocking via api. Updated documentation. Report % compression via log file.
1 parent 896aff7 commit 9fdd9cd

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ _Image taken from blogs.dropbox.com_
2020

2121
If a change is made to the video file, for example an extra 1mb of data is appended and uploaded. Then the document will now exist as h1, h2, h3 and the newly created h5. h4 will remain stored and be returned if the old version of the document is requested.
2222

23-
The basis of this is taken from a [2014 tech blog from Dropbox](https://blogs.dropbox.com/tech/2014/07/streaming-file-synchronization/)
23+
The basis of this is taken from a [2014 tech blog from Dropbox](https://blogs.dropbox.com/tech/2014/07/streaming-file-synchronization/).
2424

2525
##Features
2626

@@ -39,6 +39,10 @@ The basis of this is taken from a [2014 tech blog from Dropbox](https://blogs.dr
3939
+ azure - Azure Simple Storage
4040
+ s3 - Amazon s3 storage
4141

42+
##Todo
43+
44+
- Updating a block from the block list
45+
4246
##Authorization
4347

4448
Authorization is done via a *Authorization* header sent in a request. Anonymous requests are not allowed. To authenticate a request, you must sign the request with the shared key when making the request and pass that signature as part of the request.

blocks/blocks.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ func BlockBuffer(source io.Reader) (BlockedFile, error) {
190190
// Get a 50byte secret to store the file under
191191
storeID := strings.ToLower(crypto.RandomSecret(40))
192192

193-
log.Printf("Saving Hash: %v StoreID: %v", hash, storeID)
193+
storeSize := len(storeData)
194+
log.Printf("Saving Block: %v Block: %v Store: %v (%.2f%%) StoreID: %v", hash, count, storeSize, ((float64(storeSize) / float64(count)) * 100), storeID)
194195

195196
// Commit block to repository
196197
err = BlockStore.SaveBlock(storeData, storeID)

server/handlers.go

+6
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ func BlockAndRespond(w http.ResponseWriter, content io.Reader) {
186186

187187
blockedFile, err := blocks.BlockBuffer(sourceFile)
188188

189+
if err != nil {
190+
log.Println("Error blocking file: ", err)
191+
w.WriteHeader(http.StatusInternalServerError)
192+
return
193+
}
194+
189195
w.WriteHeader(http.StatusCreated)
190196
w.Header()["Content-Type"] = []string{"application/json"}
191197
body, err := json.Marshal(blockedFile)

0 commit comments

Comments
 (0)