Skip to content

fix: come back to the listing page an import stopped in - #155

Merged
oleksandr-nc merged 3 commits into
mainfrom
fix/139/come-back-for-unfinished-pages
Sep 25, 2026
Merged

oleksandr-nc merged 3 commits into
mainfrom
fix/139/come-back-for-unfinished-pages

Conversation

@oleksandr-nc

Copy link
Copy Markdown
Contributor

Part of #139, after #142, #143 and #144: the half of it that is about files that never arrive.

What a batch that stops in a folder leaves behind

The import job downloads 500 MB, then hands over to the next run through the import_tree user setting. A directory was taken out of that tree as soon as its first listing page had been walked, and the import folder itself was never put in it — only sub-folders were. So when a batch reached its download size on the second or a later page of a listing, nothing remembered that the listing was unfinished: the next batch went through the remembered sub-folders, found nothing left to do, and the import reported itself as finished. The files behind the page it stopped in were never downloaded, nothing was written to the log, and the notification said "N files were imported from OneDrive storage."

A drive larger than one batch with at least one sub-folder is enough to hit this, which makes it a good candidate for the reports of imports that silently leave files out.

What changes

  • A directory stays in the import tree while its listing is being walked, and the value carries the page to resume at, so the next batch continues at the page the last one stopped in rather than skipping the rest of the folder. The import folder itself is in the tree like any other directory.
  • A page whose token is no longer accepted — they are short lived and a batch may run an hour later — starts its directory over from the first page, once. The files it already brought are skipped as existing ones.
  • A listing that fails for another reason is logged; it was silently swallowed.
  • The files a page skipped because they were already there are counted even when the batch runs out on that same page. The counter is written once per page, and the page that ended a batch never got to write it.

The new setting

import_batch_size says how much a single run of the import job downloads before it lets the next run continue, 500 MB by default. Servers that cannot afford that in one job can lower it, and the integration test sets it to 20 bytes so that the import has to stop in the middle of a listing page and come back to it.

Where it is covered

The stubbed drive of the Graph API test is imported a second time with the small batch size, and the job checks the drive's second listing page was fetched again, that the files behind it arrived, and that the finish notification counts the file the first batch had already brought as one that was already there.

A batch that reached its download size in the middle of a folder listing left the
rest of that listing out of the import: a directory was dropped from the import
tree once its first page had been walked, and the import folder itself was never
in the tree at all. The next batch had nothing to come back to and the import
reported itself as finished, with the files of the unfinished pages missing and
nothing in the log.

A directory now stays in the tree, carrying the page to resume at, until its
listing is exhausted. A page that cannot be listed any more, an expired token
for instance, starts the directory over from its first page, and a listing that
fails without one is logged.

The files a page skipped because they were already there are counted even when
the batch ends on that page.

Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
The import job downloads 500 MB before it lets the next run continue. On a server
where that is too much of a single job, or for a test that wants to see the import
resume, the import_batch_size app setting now says how much a batch downloads.

Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
@oleksandr-nc
oleksandr-nc force-pushed the fix/139/come-back-for-unfinished-pages branch from 94b1af5 to 9e7905a Compare September 25, 2026 10:41
The stubbed drive is imported a second time into another folder, with a batch size
of 20 bytes, so that the import runs out in the middle of the second listing page
and has to come back to it. The job checks that the page was listed again and that
the files behind it arrived.

Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
@oleksandr-nc
oleksandr-nc force-pushed the fix/139/come-back-for-unfinished-pages branch from 9e7905a to b431d4e Compare September 25, 2026 10:47
@oleksandr-nc
oleksandr-nc merged commit c4754e4 into main Sep 25, 2026
25 checks passed
@oleksandr-nc
oleksandr-nc deleted the fix/139/come-back-for-unfinished-pages branch September 25, 2026 10:56
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.

1 participant