rclone: I encountered several errors while uploading to the PIKPAK cloud drive (investigated for over a week, identified the issues, hoping to assist in fixing).

What is the problem you are having with rclone?

Recently, while using PIKPAK to upload a large amount of data, I discovered several issues (rclone shows 100% upload complete with no error messages):

Because these error will cause the uploaded files to be damaged and data to be lost, please consider repairing them as a priority if possible.

1.Duplicate Files: I found numerous duplicate files within individual directories. For instance, an original file named “file.jpg” might have duplicates named “file(1).jpg”, “file(2).jpg”, and so on. These duplicate files have identical sizes and almost identical hash codes (due to some being corrupted).

2.Unreadable Files: Some files uploaded cannot be read.

3.Missing Original Files: Occasionally, only derivative files like “file(1).jpg” are present without the original file. When attempting to manually rename these files back to their original names, an error occurs stating that the file already exists!

4.Files Sent to Trash: Some uploaded files end up in the trash.

Moreover, it’s highly probable for issues 1, 2, 3, and 4 to coexist within the same folder simultaneously, without rclone displaying any upload errors! However, reproducing the issue is straightforward: by uploading a large number of files (regardless of file size), there’s roughly a 1/50 chance of encountering an error!

As I’ve already uploaded a significant amount of data and cannot wait for rclone to be fixed, I’ve taken it upon myself to write a repair program in Python (apologies for not being proficient in Go and unable to assist in modifying rclone source code).

Below are detailed observations and some of the source code used in my repair program:

1.Identifying Unreadable Files: I observed and compared file attributes to distinguish unreadable files from those that can be read. After uploading, files with reading issues have attributes where the “platform” parameter within the “params” section equals “Upload”. Normally, there should be a “task_id” parameter, but unreadable files lack this parameter. However, there’s one exception: files with a size of zero, even if they are readable, won’t have the “task_id” parameter.

# List files in a folder
for f in files:
  if "task_id" not in params and "platform" in params and params["platform"] == "Upload":
      if int(size) > 0:
          # Code to delete unreadable files here ...

2.Identifying Hidden Files: As some duplicated files couldn’t be renamed back to their original names, I suspected that some files might be hidden. Even official software or websites couldn’t detect these hidden files; I had to compare file attributes to find them. After completion of some uploads, the processing status of these files would forever remain at “PHASE_TYPE_PENDING,” resulting in them becoming hidden and unreadable.

# List files in a folder
for f in files:
  if phase == "PHASE_TYPE_PENDING":
     # Code to delete hidden files here ...

3.Identifying Duplicate Files: Identifying duplicate files is straightforward; if their hash codes are the same, they are duplicates.

grouped_data = {}
# List files in a folder
for f in files:
  if hash not in grouped_data:
      grouped_data[hash] = []
  grouped_data[hash].append(f)
for duplicate_list in grouped_data.values():
  # Code to delete duplicate files here ...

The parts that need to be fixed in rclone aren’t complex; it just needs to check the attributes mentioned above during the upload process, identify upload failures (unreadable files), and abnormal statuses (hidden files). Only files with correct attributes should be counted as successfully uploaded; otherwise, retry the upload. As for the remaining issues (where files are duplicated or sent to the trash) , they may be caused by repeated attempts to upload failed files! Additionally, it might be worth considering adding a “dedupe” parameter to handle previously failed uploads (currently ineffective).

Since my repair code is written in Chinese, I won’t provide it here as it might appear as gibberish to non-Chinese language systems. I’m Taiwanese, and English is not my native language. This is my first time report here, so please forgive any mistakes I might make. I would like to express my gratitude for everyone’s assistance. If more information is needed, please let me know.

What is your rclone version (output from rclone version)

1.66

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Ubuntu 22.04, 64 bit

Which cloud storage system are you using? (e.g. Google Drive)

local or google drive upload to pikpak

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

rclone copy & sync

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

no error message

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don’t comment if you have no relevant information to add. It’s just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 35 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Can you try with v1.67.0-beta.7930.223ba8626.fix-7787-pikpak-upload-conflict?

We’ve made some adjustments in this version to make uploads more reliable.

Checking upload status

By implementing getTask() API call and using task_id assigned for each upload, we ensure uploads are completed successfully on the server-side.

Cancel uploads

If an upload encounters an error, we cancel it to remove residual files (hidden or unreadable).

Force sleep and min sleep

Based on experiment using 1000 small files as @cj-neo described and following commands to upload and check them,

rclone copy ./test test:test --transfers=16 --log-file=test.log --log-level=DEBUG
rclone check ./test test:test --download --log-file=test.log --log-level=DEBUG

the number of first three retries of low level retry for 1000 files are

1 2 3
826 59 28
728 135 102
662 81 63
592 85 65
517 44 34
429 68 59

meaning that 5% (~50 of 1000) files require at least three retries which is +150 ms. Therefore, introducing a forced delay (or sleep) after uploading can be a reasonable approach to ensure server-side updates take effect. Note that this doesn’t impact total execution time much.

Moreover, minimum sleep for pacer is increased from 10 to 100ms to resolve following server error.

http2: server sent GOAWAY and closed the connection; LastStreamID=1999, ErrCode=NO_ERROR, debug=""

Stop using uploadByForm()

We stop using uploadByForm() cause it is not as reliable as uploadByResumable() for a large number of small files.

Thanks for the test. I will fix it soon.