Skip to content

fix: preserve folder structure when pushing files#3

Open
admirkadriu wants to merge 1 commit intoaloth:mainfrom
admirkadriu:fix/push-preserve-folder-structure
Open

fix: preserve folder structure when pushing files#3
admirkadriu wants to merge 1 commit intoaloth:mainfrom
admirkadriu:fix/push-preserve-folder-structure

Conversation

@admirkadriu
Copy link

Summary

olcli push currently uploads all files to the project root folder, ignoring subdirectory structure. For example, a file at figures/image.png or sections/intro.tex ends up at the root level on Overleaf instead of in its respective subfolder.

Root cause: uploadFile() in client.ts strips the directory portion of the file path (fileName.split('/').pop()) and always uploads to the root folder ID.

Fix:

  • Added getFolderTreeFromSocket() to fetch the full folder hierarchy (path -> folder ID map) via the Socket.IO joinProjectResponse packet
  • Added resolveFolderId() to look up or create missing folders on demand
  • Modified uploadFile() to accept an optional folderTree parameter; when a file has a directory component, it resolves the correct subfolder ID instead of always using root
  • Updated push command to fetch the folder tree once before uploading and pass it to each uploadFile() call

Behavior:

  • Files at root level (e.g. main.tex) continue to upload to root as before
  • Files in subdirectories (e.g. figures/img.png) are now uploaded into the correct subfolder
  • If a subfolder doesn't exist on Overleaf, it is created automatically
  • The folder tree is fetched once per push (not per file), so there is no performance penalty
  • Backward compatible: callers that don't pass folderTree get the existing behavior

Test plan

  • Tested with a real Overleaf project containing figures/ and sections/ subdirectories
  • Verified files land in correct subfolders (not flattened to root)
  • Verified new folders are created when they don't exist on Overleaf
  • Verified root-level files still upload correctly
  • TypeScript compiles cleanly (npm run build)

🤖 Generated with Claude Code

@admirkadriu admirkadriu force-pushed the fix/push-preserve-folder-structure branch 2 times, most recently from 51cf727 to 701f9c4 Compare March 15, 2026 00:03
`olcli push` previously uploaded all files to the project root,
ignoring subdirectory structure (e.g. files in `figures/` or `sections/`
would end up flattened at root level).

This was caused by `uploadFile()` stripping the directory portion of the
file path and always uploading to the root folder ID.

The fix fetches the project's folder tree via Socket.IO before uploading,
then resolves each file's directory to the correct Overleaf folder ID.
Missing folders are created automatically via the folder API.
@admirkadriu admirkadriu force-pushed the fix/push-preserve-folder-structure branch from 701f9c4 to 10db25e Compare March 15, 2026 00:04
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