fix(misskey): folderId format validation and root directory handling#9376
Open
vxtls wants to merge 1 commit intoAlistGo:mainfrom
Open
fix(misskey): folderId format validation and root directory handling#9376vxtls wants to merge 1 commit intoAlistGo:mainfrom
vxtls wants to merge 1 commit intoAlistGo:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description / 描述
主要更改:
修复panic问题
put方法中添加了空值检查,避免对nil调用GetID()修复Misskey API的folderId格式问题
handleFolderId返回类型从string改为interface{}nil而不是空字符串,避免触发misskey:id格式验证错误put方法中正确处理form data,只有非根目录才添加folderId字段添加根目录检查逻辑
isRootFolder函数统一判断是否为根目录isRootFolder函数:getFiles和getFolders:根目录不传folderIdhandleFolderId:根目录返回nilput:根目录不添加folderId到formData代码优化
http.MethodPost代替手动编码的POSTMotivation and Context / 背景
为什么需要此更改?它解决了什么问题?
Panic问题:当上传文件到根目录时,
put方法中的dstDir为nil,导致dstDir.GetID()调用引发panic,此前将会导致500错误,文件在根目录将无法上传API格式验证错误:Misskey API对
folderId有misskey:id格式要求,对于根目录来说,空字符串不满足此格式,根目录不传 folderId 字段,而不是传空字符串,导致上传失败:代码一致性:之前根目录判断逻辑分散在不同方法中,使用
dir.GetPath() != "/"和dir.GetID() == ""两种不同方式,需要统一How Has This Been Tested? / 测试
测试步骤:
go fmt格式化代码,确保代码风格一致isRootFolder返回true,非根目录返回falsehandleFolderId对根目录返回nil,非根目录返回正确的ID字符串put方法中根目录不添加folderId字段,非根目录正确添加测试场景: