t3rm1n4l/go-mega

Fix for golang-1.22

Closed this issue · 1 comments

encoding := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AB"

The alphabet has non-unique characters A and B, but starting with golang-1.22 the alpahbet must be unique characters (https://pkg.go.dev/encoding/base64@go1.22.0#NewEncoding)

Is there a reason to not use the default characters + and /, i.e.

	encoding := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

The full error message that I see:

panic: encoding alphabet includes duplicate symbols

goroutine 86 [running]:
encoding/base64.NewEncoding(...)
	/usr/lib/go/src/encoding/base64/base64.go:82
github.com/t3rm1n4l/go-mega.randString(0xa)
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/go-mod/github.com/t3rm1n4l/go-mega@v0.0.0-20230228171823-a01a2cda13ca/utils.go:371 +0x299
github.com/t3rm1n4l/go-mega.(*Mega).Delete(0xc000a86000, 0xc000878270, 0xcb?)
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/go-mod/github.com/t3rm1n4l/go-mega@v0.0.0-20230228171823-a01a2cda13ca/mega.go:1825 +0x11a
github.com/rclone/rclone/backend/mega.(*Fs).deleteNode.func1()
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/backend/mega/mega.go:627 +0x45
github.com/rclone/rclone/fs.pacerInvoker(0x1, 0xa, 0x30?)
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/fs/pacer.go:88 +0x32
github.com/rclone/rclone/lib/pacer.(*Pacer).call(0xc003b16240, 0xc003b12a20, 0xa)
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/lib/pacer/pacer.go:197 +0x7c
github.com/rclone/rclone/lib/pacer.(*Pacer).Call(0xc003b16240, 0xc003b12a20)
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/lib/pacer/pacer.go:216 +0x92
github.com/rclone/rclone/backend/mega.(*Fs).deleteNode(0xc000792d00, {0x558902913e70, 0x558903a8dfe0}, 0xc000878270)
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/backend/mega/mega.go:626 +0xc5
github.com/rclone/rclone/backend/mega.(*Object).Remove(0x558902913e70?, {0x558902913e70?, 0x558903a8dfe0?})
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/backend/mega/mega.go:1202 +0x27
github.com/rclone/rclone/fs/operations.DeleteFileWithBackupDir({0x558902913e70, 0x558903a8dfe0}, {0x558902926b18, 0xc003a69480}, {0x0, 0x0})
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/fs/operations/operations.go:739 +0x279
github.com/rclone/rclone/fs/operations.DeleteFilesWithBackupDir.func1()
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/fs/operations/operations.go:774 +0xfa
created by github.com/rclone/rclone/fs/operations.DeleteFilesWithBackupDir in goroutine 70
	/home/portage/tmp/portage/net-misc/rclone-1.63.1/work/rclone-1.63.1/fs/operations/operations.go:771 +0xd4
ncw commented

I'm guessing that the randString must be alphanumeric so there is certainly a better was to generate it than the current code