@@ 453-505 (lines=53) @@ | ||
450 | def supportRecursiveMove(self, destpath: str): |
|
451 | return True |
|
452 | ||
453 | def moveRecursive(self, destpath: str): |
|
454 | """ |
|
455 | As we support recursive move, copymovesingle won't be called, though with copy it'll be called |
|
456 | but i have to check if the client ever call that function... |
|
457 | """ |
|
458 | destpath = normpath(destpath) |
|
459 | ||
460 | invalid_path = False |
|
461 | ||
462 | # if content is either deleted or archived, we'll check that we try moving it to the parent |
|
463 | # if yes, then we'll unarchive / undelete them, else the action's not allowed |
|
464 | if self.content.is_deleted or self.content.is_archived: |
|
465 | # we remove all archived and deleted from the path and we check to the destpath |
|
466 | # has to be equal or else path not valid |
|
467 | # ex: /a/b/.deleted/resource, to be valid destpath has to be = /a/b/resource (no other solution) |
|
468 | current_path = re.sub(r'/\.(deleted|archived)', '', self.path) |
|
469 | ||
470 | if current_path == destpath: |
|
471 | ManageActions( |
|
472 | action_type=ActionDescription.UNDELETION if self.content.is_deleted else ActionDescription.UNARCHIVING, |
|
473 | api=self.content_api, |
|
474 | content=self.content, |
|
475 | session=self.session, |
|
476 | ).action() |
|
477 | else: |
|
478 | invalid_path = True |
|
479 | # if the content is not deleted / archived, check if we're trying to delete / archive it by |
|
480 | # moving it to a .deleted / .archived folder |
|
481 | elif basename(dirname(destpath)) in ['.deleted', '.archived']: |
|
482 | # same test as above ^ |
|
483 | dest_path = re.sub(r'/\.(deleted|archived)', '', destpath) |
|
484 | ||
485 | if dest_path == self.path: |
|
486 | ManageActions( |
|
487 | action_type=ActionDescription.DELETION if '.deleted' in destpath else ActionDescription.ARCHIVING, |
|
488 | api=self.content_api, |
|
489 | content=self.content, |
|
490 | session=self.session, |
|
491 | ).action() |
|
492 | else: |
|
493 | invalid_path = True |
|
494 | # else we check if the path is good (not at the root path / not in a deleted/archived path) |
|
495 | # and we move the content |
|
496 | else: |
|
497 | invalid_path = any(x in destpath for x in ['.deleted', '.archived']) |
|
498 | invalid_path = invalid_path or any(x in self.path for x in ['.deleted', '.archived']) |
|
499 | invalid_path = invalid_path or dirname(destpath) == self.environ['http_authenticator.realm'] |
|
500 | ||
501 | if not invalid_path: |
|
502 | self.move_folder(destpath) |
|
503 | ||
504 | if invalid_path: |
|
505 | raise DAVError(HTTP_FORBIDDEN) |
|
506 | ||
507 | def move_folder(self, destpath): |
|
508 | ||
@@ 1163-1213 (lines=51) @@ | ||
1160 | session=self.session, |
|
1161 | ) |
|
1162 | ||
1163 | def moveRecursive(self, destpath): |
|
1164 | """As we support recursive move, copymovesingle won't be called, though with copy it'll be called |
|
1165 | but i have to check if the client ever call that function...""" |
|
1166 | destpath = normpath(destpath) |
|
1167 | ||
1168 | invalid_path = False |
|
1169 | ||
1170 | # if content is either deleted or archived, we'll check that we try moving it to the parent |
|
1171 | # if yes, then we'll unarchive / undelete them, else the action's not allowed |
|
1172 | if self.content.is_deleted or self.content.is_archived: |
|
1173 | # we remove all archived and deleted from the path and we check to the destpath |
|
1174 | # has to be equal or else path not valid |
|
1175 | # ex: /a/b/.deleted/resource, to be valid destpath has to be = /a/b/resource (no other solution) |
|
1176 | current_path = re.sub(r'/\.(deleted|archived)', '', self.path) |
|
1177 | ||
1178 | if current_path == destpath: |
|
1179 | ManageActions( |
|
1180 | action_type=ActionDescription.UNDELETION if self.content.is_deleted else ActionDescription.UNARCHIVING, |
|
1181 | api=self.content_api, |
|
1182 | content=self.content, |
|
1183 | session=self.session, |
|
1184 | ).action() |
|
1185 | else: |
|
1186 | invalid_path = True |
|
1187 | # if the content is not deleted / archived, check if we're trying to delete / archive it by |
|
1188 | # moving it to a .deleted / .archived folder |
|
1189 | elif basename(dirname(destpath)) in ['.deleted', '.archived']: |
|
1190 | # same test as above ^ |
|
1191 | dest_path = re.sub(r'/\.(deleted|archived)', '', destpath) |
|
1192 | ||
1193 | if dest_path == self.path: |
|
1194 | ManageActions( |
|
1195 | action_type=ActionDescription.DELETION if '.deleted' in destpath else ActionDescription.ARCHIVING, |
|
1196 | api=self.content_api, |
|
1197 | content=self.content, |
|
1198 | session=self.session, |
|
1199 | ).action() |
|
1200 | else: |
|
1201 | invalid_path = True |
|
1202 | # else we check if the path is good (not at the root path / not in a deleted/archived path) |
|
1203 | # and we move the content |
|
1204 | else: |
|
1205 | invalid_path = any(x in destpath for x in ['.deleted', '.archived']) |
|
1206 | invalid_path = invalid_path or any(x in self.path for x in ['.deleted', '.archived']) |
|
1207 | invalid_path = invalid_path or dirname(destpath) == self.environ['http_authenticator.realm'] |
|
1208 | ||
1209 | if not invalid_path: |
|
1210 | self.move_file(destpath) |
|
1211 | ||
1212 | if invalid_path: |
|
1213 | raise DAVError(HTTP_FORBIDDEN) |
|
1214 | ||
1215 | def move_file(self, destpath: str) -> None: |
|
1216 | """ |