|
25 | 25 | from .common import CHUNK_SIZE, ClientError, DeltaChangeType, PullActionType |
26 | 26 | from .models import ProjectDelta, ProjectDeltaChange, PullAction |
27 | 27 | from .merginproject import MerginProject |
28 | | -from .utils import cleanup_tmp_dir, save_to_file |
| 28 | +from .utils import cleanup_tmp_dir, save_to_file, is_path_too_long |
29 | 29 | from typing import List, Optional |
30 | 30 |
|
31 | 31 | # status = download_project_async(...) |
@@ -480,6 +480,12 @@ def get_download_diff_files(delta_item: ProjectDeltaChange, target_dir: str) -> |
480 | 480 |
|
481 | 481 | for diff in delta_item.diffs: |
482 | 482 | dest_file_path = os.path.normpath(os.path.join(target_dir, diff.id)) |
| 483 | + if is_path_too_long(dest_file_path): |
| 484 | + raise ClientError( |
| 485 | + f"Cannot download diff for '{delta_item.path}': diff file path is too long " |
| 486 | + f"({len(dest_file_path)} characters) for this OS: {dest_file_path}\n" |
| 487 | + "Move the project to a directory with a shorter path and try again." |
| 488 | + ) |
483 | 489 | download_items = get_download_items(delta_item.path, diff.size, diff.version, target_dir, diff.id, True) |
484 | 490 | result.append(DownloadFile(dest_file_path, download_items)) |
485 | 491 | return result |
@@ -574,12 +580,15 @@ def pull_project_async(mc, directory) -> Optional[PullJob]: |
574 | 580 | # if we have conflict and diff update, download the diff files |
575 | 581 | if v2_pull_enabled: |
576 | 582 | # using v2 endpoint to download diff files, without chunks. Then we are creating DownloadDiffQueueItem instances for each diff file. |
577 | | - diff_files.extend( |
578 | | - [ |
579 | | - DownloadDiffQueueItem(diff_item.id, os.path.join(tmp_dir.name, diff_item.id)) |
580 | | - for diff_item in change.diffs |
581 | | - ] |
582 | | - ) |
| 583 | + for diff_item in change.diffs: |
| 584 | + diff_path = os.path.join(tmp_dir.name, diff_item.id) |
| 585 | + if is_path_too_long(diff_path): |
| 586 | + raise ClientError( |
| 587 | + f"Cannot download diff for '{change.path}': diff file path is too long " |
| 588 | + f"({len(diff_path)} characters) for this OS: {diff_path}\n" |
| 589 | + "Move the project to a directory with a shorter path and try again." |
| 590 | + ) |
| 591 | + diff_files.append(DownloadDiffQueueItem(diff_item.id, diff_path)) |
583 | 592 | basefiles_to_patch.append((change.path, [diff.id for diff in change.diffs])) |
584 | 593 |
|
585 | 594 | else: |
@@ -830,6 +839,12 @@ def download_diffs_async(mc, project_directory, file_path, versions): |
830 | 839 | diff_only=True, |
831 | 840 | ) |
832 | 841 | dest_file_path = mp.fpath_cache(diff["path"], version=file["version"]) |
| 842 | + if is_path_too_long(dest_file_path): |
| 843 | + raise ClientError( |
| 844 | + f"Cannot download diff for '{file.get('path')}': diff file path is too long " |
| 845 | + f"({len(dest_file_path)} characters) for this OS: {dest_file_path}\n" |
| 846 | + "Move the project to a directory with a shorter path and try again." |
| 847 | + ) |
833 | 848 | if os.path.exists(dest_file_path): |
834 | 849 | continue |
835 | 850 | download_files.append(DownloadFile(dest_file_path, items)) |
|
0 commit comments