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

backend: Add Apple iCloud Drive backend #7717

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

lostb1t
Copy link

@lostb1t lostb1t commented Apr 2, 2024

What is the purpose of this change?

Add support for a new backend, iCloud Drive

Was the change discussed in an issue or in the forum before?

#1778

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

Notes

This feature branch is in a working state, feedback on finished implementations is appreciated. Ill keep it in draft untill everything is implemented and ill update the TODO accordingly

This PR is only for iCloud Drive. Ill continue work on Photos once this PR is merged.

Todo

Rclone Interfaces

Fs
  • List
  • Mkdir
  • Rmdir
  • Put
Object
  • Open
  • Update
  • Remove
Mover
  • Move
DirMove
  • DirMove
Copier
  • Copy

@ncw
Copy link
Member

ncw commented Apr 2, 2024

Nice work :-)

Some quick questions

  • where did the client_id come from?
  • are you running through the integration tests?

Thank you

@lostb1t
Copy link
Author

lostb1t commented Apr 2, 2024

Nice work :-)

Some quick questions

  • where did the client_id come from?
  • are you running through the integration tests?

Thank you

not sure what client_id you are referring to? and no I havent run any integration test yet.
Will do whenimplemented all interfaces.

@lostb1t
Copy link
Author

lostb1t commented Apr 4, 2024

fyi: so iCloud doesn't have functionality for updating/replacing files. At least not something I can find reverse engineering

So if a file exists I move it to iCloud trash. And upload a new version of the file.
After successful upload the file is removed from trash or restored from trash if upload failed.

@lostb1t
Copy link
Author

lostb1t commented Apr 5, 2024

@ncw how one handle folder invalidation? drive uses etags for files and folders. If a file or folder within a folder changes then the parent folders etag changes. This means I have to clear almost the whole tree from child to parent.

Not sure how to handle that in general, what if a users change it locally but file/folder has changed remotely in between. What error should I raise on that? (if etags are not matching)

cachedir doesn't seem to refresh after invalidation, see:

// TODO: wing it for now. Dont know why it doesnt pick up refreshed entries after flushing

When calling flushdir at the end of rmdir I see the call for FindLeaf but the cachedir entries aren't updated.

@ncw
Copy link
Member

ncw commented Apr 5, 2024

@lostb1t

not sure what client_id you are referring to?

This one at the top of the source!

clientId      = "e9f98057fb916de2bbd755ef280d7257146a76e5118f27ab2e9a3d065c20c17e"

and no I haven't run any integration test yet. Will do when implemented all interfaces.

Running the integration tests will guide you through what you need to do. You can start running them as soon as you've done List.

fyi: so iCloud doesn't have functionality for updating/replacing files. At least not something I can find reverse engineering

So if a file exists I move it to iCloud trash. And upload a new version of the file. After successful upload the file is removed from trash or restored from trash if upload failed.

Seems OK!

how one handle folder invalidation? drive uses etags for files and folders. If a file or folder within a folder changes then the parent folders etag changes. This means I have to clear almost the whole tree from child to parent.
Not sure how to handle that in general, what if a users change it locally but file/folder has changed remotely in between. What error should I raise on that? (if etags are not matching)

Do you have to use the etags? They are optional for most cloud storage systems and rclone doesn't use them. This means that the last write wins which is what we want. If you can't ignore etags then refresh the etag and try again.

cachedir doesn't seem to refresh after invalidation, see:

// TODO: wing it for now. Dont know why it doesnt pick up refreshed entries after flushing

When calling flushdir at the end of rmdir I see the call for FindLeaf but the cachedir entries aren't updated.

Not sure!

@lostb1t
Copy link
Author

lostb1t commented Apr 5, 2024

@lostb1t

not sure what client_id you are referring to?

This one at the top of the source!

clientId      = "e9f98057fb916de2bbd755ef280d7257146a76e5118f27ab2e9a3d065c20c17e"

and no I haven't run any integration test yet. Will do when implemented all interfaces.

Running the integration tests will guide you through what you need to do. You can start running them as soon as you've done List.

fyi: so iCloud doesn't have functionality for updating/replacing files. At least not something I can find reverse engineering
So if a file exists I move it to iCloud trash. And upload a new version of the file. After successful upload the file is removed from trash or restored from trash if upload failed.

Seems OK!

how one handle folder invalidation? drive uses etags for files and folders. If a file or folder within a folder changes then the parent folders etag changes. This means I have to clear almost the whole tree from child to parent.
Not sure how to handle that in general, what if a users change it locally but file/folder has changed remotely in between. What error should I raise on that? (if etags are not matching)

Do you have to use the etags? They are optional for most cloud storage systems and rclone doesn't use them. This means that the last write wins which is what we want. If you can't ignore etags then refresh the etag and try again.

cachedir doesn't seem to refresh after invalidation, see:

// TODO: wing it for now. Dont know why it doesnt pick up refreshed entries after flushing

When calling flushdir at the end of rmdir I see the call for FindLeaf but the cachedir entries aren't updated.

Not sure!

etags are needed for file operations unfortunately, but I can just refresh it when it got stale.

the clientid is a static that icloud.com uses. So I reuse it to mimic the browser.

@lostb1t
Copy link
Author

lostb1t commented Apr 9, 2024

@ncw small question. iCloud Drive does not allow uploading empty files so check the size and raise ErrorCantUploadEmptyFiles when its 0

But when using macOS finder to copy a file, I get an partial file with zero length (while the actually file isn't empty)

Not sure howto handle this.

@ncw
Copy link
Member

ncw commented Apr 10, 2024

@lostb1t

small question. iCloud Drive does not allow uploading empty files so check the size and raise ErrorCantUploadEmptyFiles when its 0

That sounds correct.

But when using macOS finder to copy a file, I get an partial file with zero length (while the actually file isn't empty)

Are you using rclone mount in the finder?

So you are seeing a zero length file in the finder? I'm not sure what you mean by a partial file?

Can you reproduce this without the rclone mount? So using rclone copy? If so please paste your command line and the log with -vv.

@lostb1t
Copy link
Author

lostb1t commented Apr 11, 2024

Its slow but finished alle interfaces and all integration test are passing 🎉

Only documentation left before its ready for review.

@ncw
Copy link
Member

ncw commented Apr 13, 2024

Its slow but finished all interfaces and all integration test are passing 🎉

Well done!

You are running the full suite from test_all?

Only documentation left before its ready for review.

:-)

@epetousis
Copy link

@lostb1t not sure if it's too early for bug reports, but currently it looks like app folders aren't being represented as folders, but rather as files.

@lostb1t
Copy link
Author

lostb1t commented Apr 14, 2024

@lostb1t not sure if it's too early for bug reports, but currently it looks like app folders aren't being represented as folders, but rather as files.

bug reports are welcome. Will fix with the following pass, tnx

@lostb1t
Copy link
Author

lostb1t commented Apr 15, 2024

@epetousis this has been fixed

@lostb1t
Copy link
Author

lostb1t commented Apr 15, 2024

crap i broke my icloud. Too many trash items and now the endpoint is broken lol

the icloud web api is a mess

@lostb1t lostb1t changed the title backend: Add Apple iCloud (drive) backend backend: Add Apple iCloud Drive backend Apr 15, 2024
@epetousis
Copy link

Fix works great. Much appreciated!

@cyayon
Copy link

cyayon commented Apr 19, 2024

Hi,
I setup successfully and authentication seems ok, but I do not see any files or directories on my iCloud account.
I tried ls, lsl, lsd... no file.

thanks.

@lostb1t
Copy link
Author

lostb1t commented Apr 20, 2024

Hi,

I setup successfully and authentication seems ok, but I do not see any files or directories on my iCloud account.

I tried ls, lsl, lsd... no file.

thanks.

@cyayon Could you post a log from the command with the -vv flag (e.g. output from rclone -vv ls

@lostb1t
Copy link
Author

lostb1t commented Apr 25, 2024

maybe removing and readding ylur remote might work (new credentials)

if not then im blaming Apple lol, try again tomorrow?

@cyayon
Copy link

cyayon commented Apr 25, 2024

I wil try again tomorrow.
But for information, I logged to iCloud with browser (safari on macOS) and my clientId in headers from https://idmsa.apple.com/appleauth/auth/authorize/signin is : d39ba9916b725105xxxxxxxxxxxxxxxxxxxxxxxxxxxx8d9d1a815d

it is different from yours.

@cyayon
Copy link

cyayon commented Apr 25, 2024

just tried to replace clienId in backend/icloud/api/client.go with mine clientId, and test. no change, same issue.

@cescofry
Copy link

Since this morning I am seeing a very similar error.
I would exclude rate limiting since I am not using my main icloud account, therefore I have only a handful of files.

2024/04/24 20:21:57 NOTICE: Time may be set wrong - time from "p109-docws.icloud.com" is -15h11m26.497311883s different from this computer
2024/04/24 20:22:04 ERROR : IO error: HTTP error 503 (503 Service Unavailable) returned body: ""
2024/04/24 20:22:24 ERROR : IO error: HTTP error 503 (503 Service Unavailable) returned body: ""
2024/04/24 20:22:44 ERROR : IO error: HTTP error 503 (503 Service Unavailable) returned body: ""
2024/04/24 20:23:05 ERROR : IO error: HTTP error 503 (503 Service Unavailable) returned body: ""

@cyayon
Copy link

cyayon commented Apr 25, 2024

ClientId ban by apple ?

@cyayon
Copy link

cyayon commented Apr 26, 2024

Hi,
Same issue persist this morning (from France).
All others apps which use iCloud seems to work correctly.
Did you try to download a file (sync or copy) on your side ?

@lostb1t
Copy link
Author

lostb1t commented Apr 26, 2024

does downloading the file from icloud.com work?

@cyayon
Copy link

cyayon commented Apr 26, 2024

Yes of course

@lostb1t
Copy link
Author

lostb1t commented Apr 26, 2024

well its the same api rclone uses so if that works then might be on my side. Might be they are blocking yeah, figure out on what, might be the user agent.

could you try with something like

--user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 Firefox/103.0

@cyayon
Copy link

cyayon commented Apr 26, 2024

Hi,
Same issue, always 503 error from iCloud and as soon as there is something to download.

@cyayon
Copy link

cyayon commented Apr 27, 2024

Hi,

I tried to fully re-create config and re-authenticate on iCloud, also with my "own" clientId (found in headers on iCloud.com).
No change, always get 503 error.

2024/04/27 17:44:22 DEBUG : Library_bear.tgz.7z: Need to transfer - File not found at Destination
2024/04/27 17:44:22 DEBUG : Library_goodlinks.tgz.7z: Need to transfer - File not found at Destination
2024/04/27 17:44:22 DEBUG : Library_notes.tgz.7z: Need to transfer - File not found at Destination
2024/04/27 17:44:22 DEBUG : Local file system at /Users/cya/tmp/icloud: Waiting for checks to finish
2024/04/27 17:44:22 DEBUG : Local file system at /Users/cya/tmp/icloud: Waiting for transfers to finish
2024/04/27 17:44:22 DEBUG : pacer: low level retry 1/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")
2024/04/27 17:44:22 DEBUG : pacer: Rate limited, increasing sleep to 20ms
2024/04/27 17:44:22 DEBUG : pacer: low level retry 1/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")
2024/04/27 17:44:22 DEBUG : pacer: Rate limited, increasing sleep to 40ms
2024/04/27 17:44:22 DEBUG : pacer: low level retry 1/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")
2024/04/27 17:44:22 DEBUG : pacer: Rate limited, increasing sleep to 80ms
2024/04/27 17:44:23 DEBUG : pacer: low level retry 2/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")
2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 160ms
2024/04/27 17:44:23 DEBUG : pacer: low level retry 2/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")
2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 320ms
2024/04/27 17:44:23 DEBUG : pacer: low level retry 2/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")
2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 640ms
2024/04/27 17:44:23 DEBUG : pacer: low level retry 3/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")
2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 1.28s
^C2024/04/27 17:44:23 INFO  : Signal received: interrupt

@pedrohgmacedo
Copy link

Hi,

I tried to fully re-create config and re-authenticate on iCloud, also with my "own" clientId (found in headers on iCloud.com).

No change, always get 503 error.


2024/04/27 17:44:22 DEBUG : Library_bear.tgz.7z: Need to transfer - File not found at Destination

2024/04/27 17:44:22 DEBUG : Library_goodlinks.tgz.7z: Need to transfer - File not found at Destination

2024/04/27 17:44:22 DEBUG : Library_notes.tgz.7z: Need to transfer - File not found at Destination

2024/04/27 17:44:22 DEBUG : Local file system at /Users/cya/tmp/icloud: Waiting for checks to finish

2024/04/27 17:44:22 DEBUG : Local file system at /Users/cya/tmp/icloud: Waiting for transfers to finish

2024/04/27 17:44:22 DEBUG : pacer: low level retry 1/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")

2024/04/27 17:44:22 DEBUG : pacer: Rate limited, increasing sleep to 20ms

2024/04/27 17:44:22 DEBUG : pacer: low level retry 1/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")

2024/04/27 17:44:22 DEBUG : pacer: Rate limited, increasing sleep to 40ms

2024/04/27 17:44:22 DEBUG : pacer: low level retry 1/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")

2024/04/27 17:44:22 DEBUG : pacer: Rate limited, increasing sleep to 80ms

2024/04/27 17:44:23 DEBUG : pacer: low level retry 2/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")

2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 160ms

2024/04/27 17:44:23 DEBUG : pacer: low level retry 2/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")

2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 320ms

2024/04/27 17:44:23 DEBUG : pacer: low level retry 2/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")

2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 640ms

2024/04/27 17:44:23 DEBUG : pacer: low level retry 3/10 (error HTTP error 503 (503 Service Unavailable) returned body: "")

2024/04/27 17:44:23 DEBUG : pacer: Rate limited, increasing sleep to 1.28s

^C2024/04/27 17:44:23 INFO  : Signal received: interrupt

I'm getting the same errors here.

@lostb1t
Copy link
Author

lostb1t commented May 1, 2024

Alright this should be fixed. At least in my testing, let me know if it still occures.

PS the old way def worked before as i run all the unit test without issue. And where now failing. So either Apple decided to kill it or they borked the endpoint. Either way, now using (a slower) other method

@cyayon
Copy link

cyayon commented May 1, 2024

Hi,

With the last patch today, it is better. Some download work as expected.
But with another directory download I have this error :

024/05/01 18:11:20 DEBUG : Added delayed dir = "Perso/nbux/recovery", newDst=Perso/nbux/recovery
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x1ecb8e7]

goroutine 93 [running]:
github.com/rclone/rclone/backend/icloud/api.(*DriveService).GetDownloadURLByDriveID(0xc000f16d80, {0x3aa73d0, 0xc000f26820}, {0xc0007f9f50?, 0x3a?})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/api/drive.go:228 +0x2e7
github.com/rclone/rclone/backend/icloud.(*Object).Open.func1()
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/icloud.go:1038 +0xe5
github.com/rclone/rclone/fs.pacerInvoker(0x1, 0xa, 0x50?)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/pacer.go:88 +0x32
github.com/rclone/rclone/lib/pacer.(*Pacer).call(0xc000f220c0, 0xc000814050, 0xa)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/lib/pacer/pacer.go:197 +0x7c
github.com/rclone/rclone/lib/pacer.(*Pacer).Call(0xc000f220c0, 0xc000814050)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/lib/pacer/pacer.go:216 +0x92
github.com/rclone/rclone/backend/icloud.(*Object).Open(0xc000ed6320, {0x3aa73d0, 0xc000f26820}, {0xc0009d0010, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/icloud.go:1032 +0x329
github.com/rclone/rclone/fs/operations.(*ReOpen).open(0xc000254d20)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:145 +0xc5
github.com/rclone/rclone/fs/operations.NewReOpen({0x3aa73d0, 0xc000f26820}, {0x3abd140, 0xc000ed6320}, 0xa, {0xc0009d0010, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:102 +0x50b
github.com/rclone/rclone/fs/operations.Open({0x3aa73d0, 0xc000f26820}, {0x3abd140, 0xc000ed6320}, {0xc0009d0010, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:124 +0x6b
github.com/rclone/rclone/fs/operations.(*copy).manualCopy(0xc000612510, {0x3aa73d0, 0xc000f26820})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:253 +0x4e5
github.com/rclone/rclone/fs/operations.(*copy).copy(0xc000612510, {0x3aa73d0, 0xc000f26820})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:302 +0x16c
github.com/rclone/rclone/fs/operations.Copy({0x3aa73d0, 0xc000f26820}, {0x3abd610, 0xc000f483c0}, {0x0, 0x0}, {0xc000b80180, 0x13}, {0x3abd140, 0xc000ed6320})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:404 +0x485
github.com/rclone/rclone/fs/sync.(*syncCopyMove).pairCopyOrMove(0xc00017ca08, {0x3aa73d0, 0xc000f26820}, 0xc000f26780, {0x3abd610, 0xc000f483c0}, 0x32, 0x0?)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/sync/sync.go:498 +0x205
created by github.com/rclone/rclone/fs/sync.(*syncCopyMove).startTransfers in goroutine 1
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/sync/sync.go:528 +0x6b

@cyayon
Copy link

cyayon commented May 1, 2024

after the last commit 98ebc42, I got the same error.
With the same directory (an obsidian vault on iCloud).

2024/05/01 19:19:50 DEBUG : Perso/perso/family/Maman.md: Need to transfer - File not found at Destination
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1ecbb12]

goroutine 102 [running]:
github.com/rclone/rclone/backend/icloud/api.(*DriveService).DownloadFile(0xc000ec0d80, {0x3aa73d0, 0xc000ecc5f0}, {0x0, 0x0}, {0xc000970870, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/api/drive.go:253 +0x192
github.com/rclone/rclone/backend/icloud.(*Object).Open.func1()
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/icloud.go:1040 +0x139
github.com/rclone/rclone/fs.pacerInvoker(0x1, 0xa, 0x50?)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/pacer.go:88 +0x32
github.com/rclone/rclone/lib/pacer.(*Pacer).call(0xc000ec8180, 0xc00110c690, 0xa)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/lib/pacer/pacer.go:197 +0x7c
github.com/rclone/rclone/lib/pacer.(*Pacer).Call(0xc000ec8180, 0xc00110c690)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/lib/pacer/pacer.go:216 +0x92
github.com/rclone/rclone/backend/icloud.(*Object).Open(0xc000f481e0, {0x3aa73d0, 0xc000ecc5f0}, {0xc000970870, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/icloud.go:1032 +0x329
github.com/rclone/rclone/fs/operations.(*ReOpen).open(0xc000ed80e0)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:145 +0xc5
github.com/rclone/rclone/fs/operations.NewReOpen({0x3aa73d0, 0xc000ecc5f0}, {0x3abd140, 0xc000f481e0}, 0xa, {0xc000970870, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:102 +0x50b
github.com/rclone/rclone/fs/operations.Open({0x3aa73d0, 0xc000ecc5f0}, {0x3abd140, 0xc000f481e0}, {0xc000970870, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:124 +0x6b
github.com/rclone/rclone/fs/operations.(*copy).manualCopy(0xc0009a25a0, {0x3aa73d0, 0xc000ecc5f0})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:253 +0x4e5
github.com/rclone/rclone/fs/operations.(*copy).copy(0xc0009a25a0, {0x3aa73d0, 0xc000ecc5f0})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:302 +0x16c
github.com/rclone/rclone/fs/operations.Copy({0x3aa73d0, 0xc000ecc5f0}, {0x3abd610, 0xc000eec1e0}, {0x0, 0x0}, {0xc0009055c0, 0x13}, {0x3abd140, 0xc000f481e0})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:404 +0x485
github.com/rclone/rclone/fs/sync.(*syncCopyMove).pairCopyOrMove(0xc0004dca08, {0x3aa73d0, 0xc000ecc5f0}, 0xc000ecc550, {0x3abd610, 0xc000eec1e0}, 0x19, 0x0?)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/sync/sync.go:498 +0x205
created by github.com/rclone/rclone/fs/sync.(*syncCopyMove).startTransfers in goroutine 1
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/sync/sync.go:528 +0x6b

when I relaunch (same directory source) :

2024/05/01 19:23:43 DEBUG : Added delayed dir = "Somfy/.obsidian/plugins/webpage-html-export", newDst=Somfy/.obsidian/plugins/webpage-html-export
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1ecbb12]

goroutine 99 [running]:
github.com/rclone/rclone/backend/icloud/api.(*DriveService).DownloadFile(0xc000bf7c40, {0x3aa73d0, 0xc000d9c280}, {0x0, 0x0}, {0xc00063bb00, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/api/drive.go:253 +0x192
github.com/rclone/rclone/backend/icloud.(*Object).Open.func1()
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/icloud.go:1040 +0x139
github.com/rclone/rclone/fs.pacerInvoker(0x1, 0xa, 0x50?)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/pacer.go:88 +0x32
github.com/rclone/rclone/lib/pacer.(*Pacer).call(0xc000d1c180, 0xc001092960, 0xa)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/lib/pacer/pacer.go:197 +0x7c
github.com/rclone/rclone/lib/pacer.(*Pacer).Call(0xc000d1c180, 0xc001092960)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/lib/pacer/pacer.go:216 +0x92
github.com/rclone/rclone/backend/icloud.(*Object).Open(0xc000dc45a0, {0x3aa73d0, 0xc000d9c280}, {0xc00063bb00, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/backend/icloud/icloud.go:1032 +0x329
github.com/rclone/rclone/fs/operations.(*ReOpen).open(0xc000cb40e0)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:145 +0xc5
github.com/rclone/rclone/fs/operations.NewReOpen({0x3aa73d0, 0xc000d9c280}, {0x3abd140, 0xc000dc45a0}, 0xa, {0xc00063bb00, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:102 +0x50b
github.com/rclone/rclone/fs/operations.Open({0x3aa73d0, 0xc000d9c280}, {0x3abd140, 0xc000dc45a0}, {0xc00063bb00, 0x1, 0x1})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/reopen.go:124 +0x6b
github.com/rclone/rclone/fs/operations.(*copy).manualCopy(0xc0010ee510, {0x3aa73d0, 0xc000d9c280})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:253 +0x4e5
github.com/rclone/rclone/fs/operations.(*copy).copy(0xc0010ee510, {0x3aa73d0, 0xc000d9c280})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:302 +0x16c
github.com/rclone/rclone/fs/operations.Copy({0x3aa73d0, 0xc000d9c280}, {0x3abd610, 0xc000dc4000}, {0x0, 0x0}, {0xc000d8ee40, 0x26}, {0x3abd140, 0xc000dc45a0})
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/operations/copy.go:404 +0x485
github.com/rclone/rclone/fs/sync.(*syncCopyMove).pairCopyOrMove(0xc0008e2008, {0x3aa73d0, 0xc000d9c280}, 0xc000d9c1e0, {0x3abd610, 0xc000dc4000}, 0x4b, 0x634a773065737133?)
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/sync/sync.go:498 +0x205
created by github.com/rclone/rclone/fs/sync.(*syncCopyMove).startTransfers in goroutine 1
        /home/pkg/pkgbuild/rclone/rclone-icloud/rclone/fs/sync/sync.go:528 +0x6b

@lostb1t
Copy link
Author

lostb1t commented May 1, 2024

@cyayon thanks for pointing me in the right direction, this was a bug with application files and has been fixed.

@cyayon
Copy link

cyayon commented May 1, 2024

Great, perfect !

Just a suggestion, I think it would be a good thing if we you could specify a different clientId in config (rclone config question). My clientId in web headers is different from yours (d39ba9916b725105xxxxxxxxxxxxxxxxd9d1a815d).

@lostb1t
Copy link
Author

lostb1t commented May 1, 2024

yeah ill check it out and replace it when i have the change

@cyayon
Copy link

cyayon commented May 1, 2024

Great !

Another thing, I found the download very slow (about 1MB/s) for a large 3GB file.

When using Finder, the download speed is much higher (about 20MB/s).

Is there some reason ?

Thank you very much.

@lostb1t
Copy link
Author

lostb1t commented May 1, 2024

Great !

Another thing, I found the download very slow (about 1MB/s) for a large 3GB file.

When using Finder, the download speed is much higher (about 20MB/s).

Is there some reason ?

Thank you very much.

if you say finder so you mean apples native drive integration?

@cyayon
Copy link

cyayon commented May 1, 2024

Yes on macOS (and files.app on iOS).

@lostb1t
Copy link
Author

lostb1t commented May 1, 2024

different apis. Apple probaply using a private api we dont have access to. This uses the web api.

So if you want to compare use icloud.com, those speeds should
match with the rclone implementation

@cyayon
Copy link

cyayon commented May 1, 2024

I understand.
It is not really important as I use Rclone only for backup all my cloud storage accounts.
Thanks !

@hurryman2212
Copy link

With the current HEAD commit, I did rclone config with successful 2FA, and rclone mount iCloud: ~/iCloud/rclone ls iCloud:/rclone lsd iCloud: but the remote always shows nothing (0 items, Free space: 1.0PiB).

When I try to copy a non-zero-bytes file into it, when mounted, it says Cannot find PCS auth info from request:

./Sources/rclone/rclone mount --verbose iCloud: ~/iCloud
2024/05/09 20:21:54 INFO  : : poll-interval is not supported by this remote
2024/05/09 20:21:54 NOTICE: : --vfs-cache-mode writes or full is recommended for this remote as it can't stream
2024/05/09 20:22:00 NOTICE: Local file system at /tmp/rclone-spool480232071: --checksum is in use but the source and destination have no hashes in common; falling back to --size-only
2024/05/09 20:22:01 ERROR : 1.pdf: Failed to copy: GET https://p126-docws.icloud.com:443/ws/com.apple.CloudDocs/list/lookup_by_id?document_id=root&unified_format=false failed, status 400, err: HTTP error 400 (400 Bad Request) returned body: "{\n  \"uuid\" : \"9cdfa44c-a396-46a9-b175-fe5e4d414870\",\n  \"messageForDeveloper\" : \"Cannot find PCS auth info from request\",\n  \"error_code\" : \"InvalidRequestException\",\n  \"serverErrorCode\" : \"BAD_REQUEST\",\n  \"reason\" : \"Cannot find PCS auth info from request\"\n}"
2024/05/09 20:22:01 INFO  : 1.pdf: Deleted
2024/05/09 20:22:01 INFO  : Local file system at /tmp/rclone-spool480232071: Removing directory
2024/05/09 20:22:01 ERROR : 1.pdf: WriteFileHandle.New Rcat failed: GET https://p126-docws.icloud.com:443/ws/com.apple.CloudDocs/list/lookup_by_id?document_id=root&unified_format=false failed, status 400, err: HTTP error 400 (400 Bad Request) returned body: "{\n  \"uuid\" : \"9cdfa44c-a396-46a9-b175-fe5e4d414870\",\n  \"messageForDeveloper\" : \"Cannot find PCS auth info from request\",\n  \"error_code\" : \"InvalidRequestException\",\n  \"serverErrorCode\" : \"BAD_REQUEST\",\n  \"reason\" : \"Cannot find PCS auth info from request\"\n}"
2024/05/09 20:22:01 ERROR : 1.pdf: WriteFileHandle.Flush error: GET https://p126-docws.icloud.com:443/ws/com.apple.CloudDocs/list/lookup_by_id?document_id=root&unified_format=false failed, status 400, err: HTTP error 400 (400 Bad Request) returned body: "{\n  \"uuid\" : \"9cdfa44c-a396-46a9-b175-fe5e4d414870\",\n  \"messageForDeveloper\" : \"Cannot find PCS auth info from request\",\n  \"error_code\" : \"InvalidRequestException\",\n  \"serverErrorCode\" : \"BAD_REQUEST\",\n  \"reason\" : \"Cannot find PCS auth info from request\"\n}"
2024/05/09 20:22:01 ERROR : IO error: GET https://p126-docws.icloud.com:443/ws/com.apple.CloudDocs/list/lookup_by_id?document_id=root&unified_format=false failed, status 400, err: HTTP error 400 (400 Bad Request) returned body: "{\n  \"uuid\" : \"9cdfa44c-a396-46a9-b175-fe5e4d414870\",\n  \"messageForDeveloper\" : \"Cannot find PCS auth info from request\",\n  \"error_code\" : \"InvalidRequestException\",\n  \"serverErrorCode\" : \"BAD_REQUEST\",\n  \"reason\" : \"Cannot find PCS auth info from request\"\n}"
2024/05/09 20:22:01 ERROR : IO error: can't open file - writer failed
2024/05/09 20:22:01 ERROR : IO error: can't open file - writer failed

ENV: Xubuntu 24.04 (6.8.0-31-generic)

@lostb1t
Copy link
Author

lostb1t commented May 9, 2024

@hurryman2212 > do you maybe have advanced data protection enabled? thats currently not supported and need to be disabled.

@hurryman2212
Copy link

hurryman2212 commented May 9, 2024

@hurryman2212 > do you maybe have advanced data protection enabled? thats currently not supported and need to be disabled.

It has been almost a year since they introduced it and I enabled it, I think, so I have completely forgotten about it.. Thank you!

Indeed, it was due to ADP. Now, it is working fine, although performance-wise, there are some issues as @cyayon reported. On my environment, ls on each sub-directory initially after mount is very slow, so --vfs-cache-mode write|full is definitely needed here.

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.

None yet

7 participants