@@ -73,7 +73,7 @@ func listSnapshotsHndl(w http.ResponseWriter, r *http.Request) {
7373 // given file was modified.
7474 params , _ := extractParams (r )
7575 if path , ok := params ["where-file-modified" ]; ok {
76- logInfo .Printf ("scan snapshots where file: '%s' was modified\n " , path )
76+ logDebug .Printf ("scan snapshots where file: '%s' was modified\n " , path )
7777
7878 // if 'scan-snap-limit' is given, limit scan to the given value
7979 if scanSnapLimit , ok := params ["scan-snap-limit" ]; ok {
@@ -283,7 +283,14 @@ func restoreFileHndl(w http.ResponseWriter, r *http.Request) {
283283
284284 // get file-handle for the actual file
285285 actualFh , err := NewFileHandle (path )
286- if err != nil {
286+ if err == nil {
287+ // move the actual file to the backup location if the file was found
288+ if err := actualFh .MoveToBackup (); err != nil {
289+ logError .Println (err .Error ())
290+ http .Error (w , "unable to restore: " + err .Error (), 500 )
291+ return
292+ }
293+ } else if err != nil && ! os .IsNotExist (err ) {
287294 logError .Println (err .Error ())
288295 http .Error (w , "unable to restore - actual file not found: " + err .Error (), 400 )
289296 return
@@ -297,13 +304,6 @@ func restoreFileHndl(w http.ResponseWriter, r *http.Request) {
297304 return
298305 }
299306
300- // move the actual file to the backup location
301- if err := actualFh .MoveToBackup (); err != nil {
302- logError .Println (err .Error ())
303- http .Error (w , "unable to restore: " + err .Error (), 500 )
304- return
305- }
306-
307307 // copy the file from the snapshot as the actual file
308308 if err := snapFh .CopyAs (path ); err != nil {
309309 logError .Println (err .Error ())
@@ -334,7 +334,7 @@ func diffFileHndl(w http.ResponseWriter, r *http.Request) {
334334 }
335335
336336 // get parameter context-size
337- contextSize := 5
337+ contextSize := 5 // FIXME: from default value in main.go
338338 if contextSizeStr , ok := params ["context-size" ]; ok {
339339 contextSize , _ = strconv .Atoi (contextSizeStr )
340340 }
@@ -411,7 +411,7 @@ func revertChangeHndl(w http.ResponseWriter, r *http.Request) {
411411 // verify path
412412 verifyPathIsUnderZMP (path , w , r )
413413
414- //FIXME!!
414+ //FIXME: unmarshal without json.Marshal -> json.Unmarshal hack
415415 var deltas Deltas
416416 if d , ok := params ["deltas" ]; ok {
417417 js , _ := json .Marshal (d )
0 commit comments