mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-04-21 12:32:38 +00:00
azblob: fix SAS URL with embedded container name
Fixes #944 Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -545,7 +545,7 @@ func TestIdleConnections(t *testing.T) {
|
||||
cFTP.lastActivity = time.Now().Add(-24 * time.Hour).UnixNano()
|
||||
sshConn2.lastActivity = c.lastActivity
|
||||
startPeriodicChecks(100 * time.Millisecond)
|
||||
assert.Eventually(t, func() bool { return len(Connections.GetStats()) == 0 }, 1*time.Second, 200*time.Millisecond)
|
||||
assert.Eventually(t, func() bool { return len(Connections.GetStats()) == 0 }, 2*time.Second, 200*time.Millisecond)
|
||||
assert.Eventually(t, func() bool {
|
||||
Connections.RLock()
|
||||
defer Connections.RUnlock()
|
||||
|
||||
@@ -3213,7 +3213,10 @@ func TestEventRuleProviderEvents(t *testing.T) {
|
||||
// update the folder
|
||||
_, _, err = httpdtest.UpdateFolder(folder, http.StatusOK)
|
||||
assert.NoError(t, err)
|
||||
if assert.FileExists(t, outPath) {
|
||||
if assert.Eventually(t, func() bool {
|
||||
_, err := os.Stat(outPath)
|
||||
return err == nil
|
||||
}, 2*time.Second, 100*time.Millisecond) {
|
||||
content, err := os.ReadFile(outPath)
|
||||
assert.NoError(t, err)
|
||||
var folderGet vfs.BaseVirtualFolder
|
||||
|
||||
@@ -107,23 +107,24 @@ func NewAzBlobFs(connectionID, localTempDir, mountPath string, config AzBlobFsCo
|
||||
if err != nil {
|
||||
return fs, fmt.Errorf("invalid SAS URL: %w", err)
|
||||
}
|
||||
svc, err := azblob.NewServiceClientWithNoCredential(fs.config.SASURL.GetPayload(), clientOptions)
|
||||
if err != nil {
|
||||
return fs, fmt.Errorf("invalid credentials: %v", err)
|
||||
}
|
||||
if parts.ContainerName != "" {
|
||||
if fs.config.Container != "" && fs.config.Container != parts.ContainerName {
|
||||
return fs, fmt.Errorf("container name in SAS URL %#v and container provided %#v do not match",
|
||||
parts.ContainerName, fs.config.Container)
|
||||
}
|
||||
fs.config.Container = parts.ContainerName
|
||||
fs.containerClient, err = svc.NewContainerClient("")
|
||||
} else {
|
||||
if fs.config.Container == "" {
|
||||
return fs, errors.New("container is required with this SAS URL")
|
||||
}
|
||||
}
|
||||
svc, err := azblob.NewServiceClientWithNoCredential(fs.config.SASURL.GetPayload(), clientOptions)
|
||||
if err != nil {
|
||||
return fs, fmt.Errorf("invalid credentials: %v", err)
|
||||
fs.containerClient, err = svc.NewContainerClient(fs.config.Container)
|
||||
}
|
||||
fs.hasContainerAccess = false
|
||||
fs.containerClient, err = svc.NewContainerClient(fs.config.Container)
|
||||
return fs, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user