Skip to content

Commit

Permalink
ADD type assert for empty file list.
Browse files Browse the repository at this point in the history
  • Loading branch information
karminski committed Nov 9, 2023
1 parent 1e18d0c commit 0bd7da4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/illadrivesdk/drive_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
DRIVE_API_ACTION_DELETE_FILES = "DeleteFiles"
DRIVE_API_ACTION_DELETE_FILE = "DeleteFile"
DRIVE_API_ACTION_DELETE_MUTIPLE_FILE = "DeleteMutipleFile"
DRIVE_API_ACTION_RENAME_FILE = "RenameFiles"
DRIVE_API_ACTION_RENAME_FILE = "RenameFile"
)

type DriveAuthClaims struct {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/illadrivesdk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ func ExtractRawFilesFromListResponse(listResponse map[string]interface{}) ([]map
return nil, errors.New("mossing files field in list response")
}

// test if it is nil
_, assertListedFilesAsNil := listedFiles.(interface{})
if assertListedFilesAsNil {
return []map[string]interface{}{}, nil
}

// assert sub structure
listedFilesAsserted, assertListedFilesPass := listedFiles.([]interface{})
if !assertListedFilesPass {
Expand Down

0 comments on commit 0bd7da4

Please sign in to comment.