mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-15 20:06:19 +08:00
1. ensure replicated file has the same timestamp
2. upload can specify modified time by &ts=... 3. correctly return code 304
This commit is contained in:
@@ -66,7 +66,12 @@ func upload(filename string, server string, fid string) (int, error) {
|
||||
debug("Failed to open file:", filename)
|
||||
return 0, err
|
||||
}
|
||||
ret, e := operation.Upload("http://"+server+"/"+fid, path.Base(filename), fh)
|
||||
fi, fiErr := fh.Stat()
|
||||
if fiErr!=nil {
|
||||
debug("Failed to stat file:", filename)
|
||||
return 0, fiErr
|
||||
}
|
||||
ret, e := operation.Upload("http://"+server+"/"+fid+"?ts="+strconv.Itoa(int(fi.ModTime().Unix()) ), path.Base(filename), fh)
|
||||
if e != nil {
|
||||
return 0, e
|
||||
}
|
||||
|
@@ -149,7 +149,7 @@ func GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool)
|
||||
w.Header().Set("Last-Modified", time.Unix(int64(n.LastModified), 0).UTC().Format(http.TimeFormat))
|
||||
if r.Header.Get("If-Modified-Since") != "" {
|
||||
if t, parseError := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since")); parseError == nil {
|
||||
if t.Unix() <= int64(n.LastModified) {
|
||||
if t.Unix() >= int64(n.LastModified) {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user