Return the OID of the local file. This OID is then compared to `self._remote_oid` to check if the file has changed compared to the remote one. If the file did not change, we won't upload it again to prevent empty commits. For LFS files, the OID corresponds to the SHA256 of
(self)
| 543 | |
| 544 | @property |
| 545 | def _local_oid(self) -> Optional[str]: |
| 546 | """Return the OID of the local file. |
| 547 | |
| 548 | This OID is then compared to `self._remote_oid` to check if the file has changed compared to the remote one. |
| 549 | If the file did not change, we won't upload it again to prevent empty commits. |
| 550 | |
| 551 | For LFS files, the OID corresponds to the SHA256 of the file content (used a LFS ref). |
| 552 | For regular files, the OID corresponds to the SHA1 of the file content. |
| 553 | Note: this is slightly different to git OID computation since the oid of an LFS file is usually the git-SHA1 |
| 554 | of the pointer file content (not the actual file content). However, using the SHA256 is enough to detect |
| 555 | changes and more convenient client-side. |
| 556 | """ |
| 557 | if self._upload_mode is None: |
| 558 | return None |
| 559 | elif self._upload_mode == 'lfs': |
| 560 | return self.upload_info.sha256 |
| 561 | else: |
| 562 | # Regular file => compute sha1 |
| 563 | # => no need to read by chunk since the file is guaranteed to be <=5MB. |
| 564 | with self.as_file() as file: |
| 565 | return git_hash(file.read()) |
| 566 | |
| 567 | |
| 568 | def _validate_path_in_repo(path_in_repo: str) -> str: |