Skip to content

fix(mega): use newest file for same filename #8422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gdm257
Copy link

@gdm257 gdm257 commented Apr 21, 2025

Close: #8344

Mega 支持一个文件夹下有多个同名文件(duplicate names),不同版本以日期区分。

AList mega driver 的 Link() 方法会返回多个「同名」文件,但最终 AList 只会响应第一个版本(最旧的)进行列出/下载。这就导致无论你上传了多少遍,读取到的永远是最旧的版本。

PR 是对 Link() 里的同名文件进行了过滤,只保留最新版本,这样 CRUD 都能保持一致

上图,首先是 Mega 官方
image

修复前(Test in v3.42)
image

修复后(PR)
image

Mega supports duplicate names but alist does not support.
In `List()` method, driver will return multiple files with same name.
That makes alist to use oldest version file for listing/downloading.
So it is necessary to filter old same name files in a folder.
After fixes, all CRUD work normally.

Refs AlistGo#8344
Copy link

Walkthrough

此PR修复了AList mega driver在处理同名文件时总是返回最旧版本的问题。通过在Link()方法中过滤同名文件,仅保留最新版本,从而确保CRUD操作的一致性。

Changes

文件 概要
drivers/mega/driver.go 修改了Link()方法,使用map来存储文件名和对应的最新文件对象,确保返回最新版本的文件。

}
if _, ok := fn[n.GetName()]; !ok {
fn[n.GetName()] = &MegaNode{n}
} else if sameNameObj := fn[n.GetName()]; (&MegaNode{n}).ModTime().After(sameNameObj.ModTime()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确保在比较两个文件的修改时间时,ModTime()方法返回的时间是准确的,以避免错误地替换文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mega 网盘有重名文件时获取的是最旧的版本
1 participant