From d5bba6b4e10813ae0155c5ca0d1da63b3a7f3521 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Wed, 12 Jul 2017 13:27:46 +1000 Subject: [PATCH] bug fix , serve existing file before download... --- crmcache.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crmcache.go b/crmcache.go index 3805d19..71cf530 100644 --- a/crmcache.go +++ b/crmcache.go @@ -29,6 +29,10 @@ func crmcache(w http.ResponseWriter, r *http.Request) { id := attachmentid[0] path := crmcacheFileName(id) + if isFileExist(path) { + http.ServeFile(w, r, path) + return + } err = crmDownloadAttachmentAs(id, path) if err != nil { @@ -36,11 +40,6 @@ func crmcache(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "reference number is not right") } - if isFileExist(path) { - http.ServeFile(w, r, path) - return - } - w.WriteHeader(http.StatusInternalServerError) fmt.Fprintf(w, "cannot build reference cache") }