Search code examples
androidbashgitrepositoryrepo

Ctrl + C vs Ctrl + Z for pausing repo sync?


I am using repo sync to download LineageOS 15.1 after using the below init command.

repo init -u https://github.com/LineageOS/android.git -b lineage-15.1

I need to pause the sync everyday due to my internet quota restrictions. How to achieve that ?

I have seen a number of posts telling to suspend/kill the job by using :-

  • CTRL + Z and resume it later using fg (provided I don't shutdown my PC)
  • CTRL + C and then again using repo sync and it is supposed to pick it up from where it left off by skimming through the files already downloaded in the .repo folder (shutdown is allowed)

But neither of them seem to work for the users (i didn't try yet). So please let me know which one can actually work or has the highest chance of working.

References

  1. Pausing & Resume Android Repo Sync
  2. [TRICK] Pause the repo sync | Android Development and Hacking

Solution

  • I had to try so I choose CTRL + C option and it actually worked for me.

    When I ran repo sync again, I could see it skimming through already fetched files and there was a word resuming transfer mentioned right before it started downloading again. So I think its safe to say that this option can be used to effectively pause repo sync. Here is the log of the resuming part after it skimmed through the available files.

    Fetching project platform/prebuilts/go/darwin-x86
    Fetching project platform/external/piex5 MiB | 11.00 KiB/s     
    Fetching project platform/external/libchrome
    Fetching project device/generic/goldfish
    Fetching project LineageOS/android_hardware_qcom_gps00 KiB/s   
    Fetching projects:  22% (142/644)  Fetching project LineageOS/contributors-cloud-generator
    remote: Sending approximately 67.13 MiB ...        .00 KiB/s   
    remote: Counting objects: 474, done        
    remote: Finding sources: 100% (17695/17695)           
    Fetching project LineageOS/android_hardware_qcom_wlan
    Fetching project platform/external/pdfium
    ** Resuming transfer from byte position 23711744
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Reremote: Counting objects: 7289, done        
      0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0Re  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0reremote: Finding sources: 100% (7289/7289)           00 KiB/s   
      0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0Re  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0Re  0     0    0     0    0     0      0      0 --:--:--  0:00:06 --:--:--     0ReFetching project platform/external/lz495.95 KiB | 32.00 KiB/s   
    

    Update: Apart from the resuming transfer thing there is a display of percentage as shown in the line Fetching projects: 22% (142/644). This resumes from the last downloaded percentage. Also, repo sync as the name says, syncs the repositories to your directory, there is no reason for it to start a fresh. It seems like it's just a myth after all (that repo sync doesn't pick up from where it left) that confuses noobs like me.

    Update 2: I also noticed that suspending using CTRL + Z and resuming using fg may not work always and might result in a network break for the paused sync.