hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! Homework file workflows: the attachment of one file to the caller's |
| 2 | //! submission (the graded gate plus the auto-created seat it hangs off) and |
| 3 | //! the pass-through reads the download paths scope through. The blob bytes |
| 4 | //! and their ordering (blob before row on upload, row before blob on delete) |
| 5 | //! stay the web layer's — it owns `files_path`. The row writes live in |
| 6 | //! [`crate::db::homework_file`]. |
| 7 | |
| 8 | use crateDatabase; |
| 9 | use cratehomework_file; |
| 10 | use cratehomework_submission; |
| 11 | use crateHomework; |
| 12 | use crate; |
| 13 | use crateHomeworkSubmission; |
| 14 | use crateHomeworkSubmissionId; |
| 15 | use crateUser; |
| 16 | use crateAppError; |
| 17 | |
| 18 | /// The submission the file will hang off, created if absent — a photo-only |
| 19 | /// homework never types text, so an upload auto-creates an empty submission |
| 20 | /// to carry the file (an existing one's text is preserved — `upsert` is |
| 21 | /// called with `preserve_text`, so even a rival hand-in landing mid-request |
| 22 | /// keeps its text). A photo-only hand-in is a hand-in: it creates the row, |
| 23 | /// so it moves the counters, so it earns badges exactly as a text submit |
| 24 | /// does. Refused (409) when a grade has frozen the homework. |
| 25 | pub async |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | /// Persist the assembled row — the seat claim and the freeze in one |
| 57 | /// guarded insert (see [`homework_file::insert`]). `Ok(None)` is the |
| 58 | /// freeze; the web layer keeps its own wording and unlinks the blob it wrote. |
| 59 | pub async |
| 60 | |
| 61 | |
| 62 | |
| 63 | /// Delete one file row and give its seat back in the same transaction. |
| 64 | /// `Ok(None)` is the freeze biting (the caller answers 409); `Err(NotFound)` |
| 65 | /// means the row had already vanished. |
| 66 | pub async |
| 67 | |
| 68 | |
| 69 | |
| 70 | /// Read a file's row only if it belongs to `submission` — the student's |
| 71 | /// download path, behind the submission gate. |
| 72 | pub async |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | /// Read a file by id only if it hangs off a submission to `homework` — the |
| 81 | /// grader's download scoping. |
| 82 | pub async |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | /// All of `submission`'s files, newest first. |
| 91 | pub async |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 |