From ec57f43dd46699170300506f9cf3f33d0ff24f29 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 2 Aug 2021 20:15:25 -0700 Subject: [PATCH] Add deprecation flag on the directory, don't remove it entirely --- router/router_server_files.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/router/router_server_files.go b/router/router_server_files.go index 1b70f89..b8202c3 100644 --- a/router/router_server_files.go +++ b/router/router_server_files.go @@ -254,13 +254,20 @@ func getServerPullingFiles(c *gin.Context) { func postServerPullRemoteFile(c *gin.Context) { s := ExtractServer(c) var data struct { - RootPath string `binding:"required,omitempty" json:"root"` - URL string `binding:"required" json:"url"` + // Deprecated + Directory string `binding:"required_without=RootPath,omitempty" json:"directory"` + RootPath string `binding:"required_without=Directory,omitempty" json:"root"` + URL string `binding:"required" json:"url"` } if err := c.BindJSON(&data); err != nil { return } + // Handle the deprecated Directory field in the struct until it is removed. + if data.Directory != "" && data.RootPath == "" { + data.RootPath = data.Directory + } + u, err := url.Parse(data.URL) if err != nil { if e, ok := err.(*url.Error); ok {