Skip to content
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

Calling TdApi.OptimizeStorage, temp file deleted but TdApi.GetRemoteFile still return temp file path #3178

Closed
cdxf opened this issue Dec 11, 2024 · 2 comments

Comments

@cdxf
Copy link

cdxf commented Dec 11, 2024

Here is my problematic flow with TdApi.OptimizeStorage:

-- Client call TdApi.DownloadFile to download a remote file (just partial file, not completed)
-- Td create a temp file
-- Then I call TdApi.OptimizeStorage(size=0, count =0, immunity_delay=1)
-- Wail and ensure the temp has been deleted from the system.
-- Client call TdApi.GetRemoteFile with the same fileId
-- Td return result with the same path (but deleted).

Result Flows:

-- First TdApi.GetRemoteFile result:
org.drinkless.tdlib.TdApi$File@531be3c5[expectedSize=31457280,id=1,local=LocalFile {
path = "D:\project\td\example\java\tdlib-WPW0Drvs\temp\10"
canBeDownloaded = true
canBeDeleted = true
isDownloadingActive = false
isDownloadingCompleted = false
downloadOffset = 0
downloadedPrefixSize = 0
downloadedSize = 31457280
}

-- Call TdApi.OptimizeStorage(size=0, count =0, immunity_delay=1)
-- D:\project\td\example\java\tdlib-WPW0Drvs\temp\10 already deleted at this point

-- Second TdApi.GetRemoteFile:

org.drinkless.tdlib.TdApi$File@6cc4c815[expectedSize=31457280,id=1,local=LocalFile {
path = "D:\project\td\example\java\tdlib-WPW0Drvs\temp\10"
canBeDownloaded = true
canBeDeleted = true
isDownloadingActive = false
isDownloadingCompleted = false
downloadOffset = 0
downloadedPrefixSize = 0
downloadedSize = 31457280
}
,remote=RemoteFile {
id = "BQACAgUAAxkDAAELmvpnKCbH9ZMEA8fd5OdCnKN_atX1jgAC7hAAAlvoQVUr2yYTG4TFDjYE"
uniqueId = "AgAD7hAAAlvoQVU"
isUploadingActive = false
isUploadingCompleted = true
uploadedSize = 0
}
,size=0]

Expected result: TdApi.GetRemoteFile should not return the path if it is not existed (deleted by TdApi.OptimizeStorage).
What can I do in this case?

@cdxf
Copy link
Author

cdxf commented Dec 11, 2024

Call TdApi.DeleteFile to delete the file cache solves this problem.
But why doesn't TdApi.OptimizeStorage do it automatically, is it a bug?

@levlam
Copy link
Contributor

levlam commented Dec 11, 2024

For partially downloaded files TDLib doesn't know the remote file for which the file is a local copy and can't update information about the file. Given, there is no way to track all file changes and deletions, the local file path can become invalid in many ways. The app is supposed to call downloadFile before using the file to ensure that the file is present and unchanged.

@cdxf cdxf closed this as completed Dec 11, 2024
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

No branches or pull requests

2 participants