Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 520026d

Browse files
committedMar 18, 2025·
remove override arg for reconstruction
1 parent 5e4c1c8 commit 520026d

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed
 

‎pkg/http/paste.go

+5-10
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@ func resourcePasteHandler(fileCache fileutils.FileCache) handleFunc {
111111
return common.RenderJSON(w, r, response)
112112
}
113113

114-
override := r.URL.Query().Get("override") == "true"
115114
rename := r.URL.Query().Get("rename") == "true"
116-
if !override && !rename {
115+
if !rename {
117116
if _, err := files.DefaultFs.Stat(dst); err == nil {
118117
return http.StatusConflict, nil
119118
}
@@ -142,10 +141,6 @@ func resourcePasteHandler(fileCache fileutils.FileCache) handleFunc {
142141
if rename && dstType != "google" {
143142
dst = pasteAddVersionSuffix(dst, dstType, files.DefaultFs, w, r)
144143
}
145-
// Permission for overwriting the file
146-
if override {
147-
return http.StatusForbidden, nil
148-
}
149144
var same = srcType == dstType
150145
// all cloud drives of two users must be seen as diff archs
151146
var srcName, dstName string
@@ -164,7 +159,7 @@ func resourcePasteHandler(fileCache fileutils.FileCache) handleFunc {
164159
}
165160

166161
if same {
167-
err = pasteActionSameArch(r.Context(), action, srcType, src, dstType, dst, d, fileCache, override, rename, w, r)
162+
err = pasteActionSameArch(r.Context(), action, srcType, src, dstType, dst, d, fileCache, rename, w, r)
168163
} else {
169164
err = pasteActionDiffArch(r.Context(), action, srcType, src, dstType, dst, d, fileCache, w, r)
170165
}
@@ -1040,11 +1035,11 @@ func moveDelete(fileCache fileutils.FileCache, srcType, src string, ctx context.
10401035
return os.ErrInvalid
10411036
}
10421037

1043-
func pasteActionSameArch(ctx context.Context, action, srcType, src, dstType, dst string, d *common.Data, fileCache fileutils.FileCache, override, rename bool, w http.ResponseWriter, r *http.Request) error {
1038+
func pasteActionSameArch(ctx context.Context, action, srcType, src, dstType, dst string, d *common.Data, fileCache fileutils.FileCache, rename bool, w http.ResponseWriter, r *http.Request) error {
10441039
klog.Infoln("Now deal with ", action, " for same arch ", dstType)
1045-
klog.Infoln("src: ", src, ", dst: ", dst, ", override: ", override)
1040+
klog.Infoln("src: ", src, ", dst: ", dst)
10461041
if srcType == "drive" || srcType == "cache" {
1047-
patchUrl := "http://127.0.0.1:80/api/resources/" + common.EscapeURLWithSpace(strings.TrimLeft(src, "/")) + "?action=" + action + "&destination=" + common.EscapeURLWithSpace(dst) + "&override=" + strconv.FormatBool(override) + "&rename=" + strconv.FormatBool(rename)
1042+
patchUrl := "http://127.0.0.1:80/api/resources/" + common.EscapeURLWithSpace(strings.TrimLeft(src, "/")) + "?action=" + action + "&destination=" + common.EscapeURLWithSpace(dst) + "&rename=" + strconv.FormatBool(rename)
10481043
method := "PATCH"
10491044
payload := []byte(``)
10501045
klog.Infoln(patchUrl)

‎pkg/http/resource.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@ func resourcePatchHandler(fileCache fileutils.FileCache) handleFunc {
164164
return http.StatusBadRequest, err
165165
}
166166

167-
override := r.URL.Query().Get("override") == "true"
168167
rename := r.URL.Query().Get("rename") == "true"
169-
if !override && !rename {
168+
if !rename {
170169
if _, err = files.DefaultFs.Stat(dst); err == nil {
171170
return http.StatusConflict, nil
172171
}
@@ -175,12 +174,7 @@ func resourcePatchHandler(fileCache fileutils.FileCache) handleFunc {
175174
dst = addVersionSuffix(dst, files.DefaultFs, strings.HasSuffix(src, "/"))
176175
}
177176

178-
// Permission for overwriting the file
179-
if override {
180-
return http.StatusForbidden, nil
181-
}
182-
183-
klog.Infoln("Before patch action:", src, dst, action, override, rename)
177+
klog.Infoln("Before patch action:", src, dst, action, rename)
184178
err = patchAction(r.Context(), action, src, dst, d, fileCache)
185179

186180
return common.ErrToStatus(err), err

0 commit comments

Comments
 (0)
Please sign in to comment.