> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Dropbox Projects 集合

`dropboxProjects` 將一個專案對應到某位使用者 Dropbox 中的資料夾。與多位 Dropbox 使用者共用的專案，每位使用者各有一份文件。此集合屬於 Dropbox 同步：third-party-datastore（`services/third-party-datastore/app/js/StateManager.mjs`）寫入它，`dropbox` web 模組（`services/web/modules/dropbox/app/src/DropboxHandler.mjs`）讀取並清除它。沒有 Mongoose schema。

#### 欄位

| 欄位 | 型別 | 意義 | 來源 |
| - | - | - | - |
| `_id` | ObjectId | 插入時由驅動程式設定。 | `StateManager.mjs:144` |
| `userId` | ObjectId | 其 Dropbox 中有該資料夾的 Overleaf 使用者。 | `StateManager.mjs:145` |
| `projectId` | ObjectId | 同步到該資料夾的專案。 | `StateManager.mjs:146` |
| `dropboxId` | String | Dropbox 資料夾中繼資料中該資料夾的 `id`。 | `StateManager.mjs:147`、`JobProcessor.mjs:82-87`、`PullManager.mjs:138` |
| `pathLower` | String | 資料夾在 Dropbox 中的路徑，小寫且不含結尾斜線。專案資料夾位於最上層，每個專案一個，例如 Dropbox 在另一個專案的 `Thesis` 旁為其編號時為 `/thesis (1)`。 | `StateManager.mjs:14-16,148`、`PullManager.mjs:112-117` |

#### 誰寫入

| 程式碼 | 作用 |
| - | - |
| `services/third-party-datastore/app/js/StateManager.mjs:137-150`（`setProjectFolder`） | 刪除該使用者具有相同 `projectId`、`dropboxId` 或 `pathLower` 的文件，然後插入新的對應。 |
| `services/third-party-datastore/app/js/JobProcessor.mjs:58-91`（`projectFolder`） | 當 web 要求新專案或使用者被加入之專案的資料夾（`createProject`，`:245-251`），或傳送一個尚無資料夾之專案的檔案（`addEntity`，`:113`）時，在 Dropbox 中建立資料夾並記錄。 |
| `JobProcessor.mjs:174-203`（`renameProject`） | 專案重新命名移動資料夾後，記錄新路徑；資料夾已不存在時移除對應（`:190`）。 |
| `services/third-party-datastore/app/js/PullManager.mjs:119-140`（`resolveProject`） | pull 發現沒有對應的資料夾時，記錄 web 依名稱比對到的專案。 |
| `PullManager.mjs:188-207`（`applyDeletion`） | 專案資料夾在 Dropbox 中被刪除時，移除對應（`StateManager.mjs:152-157`）。 |
| `StateManager.mjs:186-190`（`removeUserState`），由 `services/third-party-datastore/app/js/QueueWorker.mjs:43` 呼叫 | third-party-datastore 解除一個無法再使用之帳戶的連結時，刪除該使用者的所有文件。 |
| `DropboxHandler.mjs:142-146`（`removeUserState`） | 在連結時（`:125`）、解除連結時（`:183`）以及已刪除使用者到期時（`services/web/modules/dropbox/index.mjs:62-64`）刪除該使用者的所有文件。 |
| `DropboxHandler.mjs:150-154`（`removeProjectState`） | 已刪除專案到期時刪除該專案的文件（`index.mjs:54-56`）。 |

#### 誰讀取

| 程式碼 | 作用 |
| - | - |
| `StateManager.mjs:130-135`（`getFolderOfProject`） | 尋找專案的資料夾：`JobProcessor.mjs:59,98,176` 與 `PullManager.mjs:133`。 |
| `StateManager.mjs:123-128`（`getProjectByFolder`） | 尋找資料夾對應的專案：`JobProcessor.mjs:65`（名稱已被使用）、`PullManager.mjs:120,197`。 |
| `StateManager.mjs:160-175`（`getSyncedPaths`） | 游標重設後列出資料夾路徑，使清單中缺少的資料夾被視為已刪除（`PullManager.mjs:74-85`）。 |
| `DropboxHandler.mjs:234-250`（`getProjectFolderName`） | 提供編輯器 Dropbox 對話方塊中顯示的資料夾名稱（`services/web/modules/dropbox/app/src/DropboxController.mjs:130`）。 |

#### 索引

| 名稱 | 鍵 | 選項 | 遷移 |
| - | - | - | - |
| `_id_` | `_id: 1` | | default |

CE 在這裡沒有其他索引。唯一索引 `projectId_userId_1` 與 `userId_dropboxId_1` 來自 `tools/migrations/20220815105500_create_dropboxProjects_index.mjs` 與 `20220817120900_create_dropboxProjects_index.mjs`，它們只帶有 `saas` 標籤，因此 CE 從不執行它們。

#### 說明

* 唯一性僅來自 `setProjectFolder` 中每次插入前的刪除（`StateManager.mjs:140-149`）。`StateManager.mjs:3-11` 的註解提到唯一索引；CE 沒有這些索引。
* 專案的對應被移除後，其資料夾仍留在 Dropbox 中。在那裡的編輯會被當作新專案讀取，與在 Dropbox 中建立的資料夾相同（`DropboxHandler.mjs:148-149`）。
* 已刪除的專案在到期前保留其對應，因為它仍可被還原（`index.mjs:52-53`）。
* 使用者的 Dropbox `list_folder` 游標不在這裡，而在 `users.dropbox.cursor` 中（`StateManager.mjs:177-184`）。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.