(self)
| 1015 | operation() |
| 1016 | |
| 1017 | def check_limits(self): |
| 1018 | |
| 1019 | # Limits for uploading |
| 1020 | # Cache's check and only re runs every x seconds |
| 1021 | if self.working_dir.file_limit_time is None or \ |
| 1022 | time.time() > self.working_dir.file_limit_time + 7200: |
| 1023 | |
| 1024 | print("[process media] Checking limits") |
| 1025 | |
| 1026 | directory_file_count = WorkingDirFileLink.file_list( |
| 1027 | session = self.session, |
| 1028 | working_dir_id = self.working_dir_id, |
| 1029 | type = "image", |
| 1030 | counts_only = True, |
| 1031 | limit = None) |
| 1032 | # Could also try to cache this as files get added... |
| 1033 | |
| 1034 | # Reject |
| 1035 | if directory_file_count >= self.directory_file_count_limit: |
| 1036 | self.input.status = "failed" |
| 1037 | self.input.status_text = "Reached a per directory limit." + \ |
| 1038 | "Please contact us to increase limit." |
| 1039 | return False |
| 1040 | # Accept and update cache |
| 1041 | else: |
| 1042 | self.session.add(self.working_dir) |
| 1043 | self.working_dir.file_limit_time = time.time() |
| 1044 | |
| 1045 | return True |
| 1046 | |
| 1047 | def try_to_commit(self): |
| 1048 | """ |
no test coverage detected