MCPcopy
hub / github.com/remotely-save/remotely-save / _writeFileFromRoot

Method _writeFileFromRoot

src/fsDropbox.ts:619–664  ·  view source on GitHub ↗
(
    key: string,
    content: ArrayBuffer,
    mtime: number,
    ctime: number,
    origKey: string
  )

Source from the content-addressed store, hash-verified

617 }
618
619 async _writeFileFromRoot(
620 key: string,
621 content: ArrayBuffer,
622 mtime: number,
623 ctime: number,
624 origKey: string
625 ): Promise<Entity> {
626 if (hasEmojiInText(origKey)) {
627 throw new Error(
628 `${origKey}: Error: Dropbox does not support emoji in file / folder names.`
629 );
630 }
631
632 const mtimeFixed = Math.floor(mtime / 1000.0) * 1000;
633 const ctimeFixed = Math.floor(ctime / 1000.0) * 1000;
634 const mtimeStr = new Date(mtimeFixed)
635 .toISOString()
636 .replace(/\.\d{3}Z$/, "Z");
637
638 // in dropbox, we don't need to create folders before uploading! cool!
639 // TODO: filesUploadSession for larger files (>=150 MB)
640
641 await retryReq(
642 () =>
643 this.dropbox.filesUpload({
644 path: key,
645 contents: content,
646 mode: {
647 ".tag": "overwrite",
648 },
649 client_modified: mtimeStr,
650 }),
651 origKey // hint
652 );
653
654 // we want to mark that parent folders are created
655 if (this.foldersCreatedBefore !== undefined) {
656 const dirs = getFolderLevels(origKey).map((x) =>
657 getDropboxPath(x, this.remoteBaseDir)
658 );
659 for (const dir of dirs) {
660 this.foldersCreatedBefore?.add(dir);
661 }
662 }
663 return await this._statFromRoot(key);
664 }
665
666 async readFile(key: string): Promise<ArrayBuffer> {
667 await this._init();

Callers 1

writeFileMethod · 0.95

Calls 5

_statFromRootMethod · 0.95
hasEmojiInTextFunction · 0.90
getFolderLevelsFunction · 0.90
retryReqFunction · 0.85
getDropboxPathFunction · 0.85

Tested by

no test coverage detected