-
Notifications
You must be signed in to change notification settings - Fork 93
add link count #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add link count #564
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,37 +11,43 @@ | |||||||||
| <th>{{ trans('cruds.document.fields.name') }}</th> | ||||||||||
| <th>{{ trans('cruds.document.fields.size') }}</th> | ||||||||||
| <th>{{ trans('cruds.document.fields.hash') }}</th> | ||||||||||
| <th>Links</th> | ||||||||||
| <th>Status</th> | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add translation keys for new column headers. Other column headers use 🌐 Proposed fix- <th>Links</th>
- <th>Status</th>
+ <th>{{ trans('cruds.document.fields.links') }}</th>
+ <th>{{ trans('cruds.document.fields.status') }}</th>Don't forget to add the corresponding keys to your language files. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| </tr> | ||||||||||
| </thead> | ||||||||||
|
|
||||||||||
| @foreach ($documents as $doc) | ||||||||||
| <tr> | ||||||||||
| <td> | ||||||||||
| {{ $doc->id }} | ||||||||||
| </td> | ||||||||||
| <td>{{ $doc->id }}</td> | ||||||||||
| <td class="text-center"> | ||||||||||
| <a href="/bob/show/{{ $doc->control_id }}">{{ $doc->control_id }}</a> | ||||||||||
| </td> | ||||||||||
| <td> | ||||||||||
| <a href="/doc/show/{{ $doc->id }}">{{ substr($doc->filename,0,32) }}</a> | ||||||||||
| <a href="/doc/show/{{ $doc->id }}">{{ substr($doc->filename, 0, 32) }}</a> | ||||||||||
| </td> | ||||||||||
| <td> | ||||||||||
| {{ \Illuminate\Support\Number::fileSize($doc->size) }} | ||||||||||
| </td> | ||||||||||
| <td> | ||||||||||
| {{ $doc->hash }} | ||||||||||
| <br> | ||||||||||
| <td>{{ \Illuminate\Support\Number::fileSize($doc->size) }}</td> | ||||||||||
| <td><small>{{ $doc->hash }}</small></td> | ||||||||||
| <td class="text-center"> | ||||||||||
| @if ($doc->file_exists) | ||||||||||
| @if ($doc->link_count > 1) | ||||||||||
| <span class="badge bg-blue">{{ $doc->link_count }}</span> | ||||||||||
| @else | ||||||||||
| {{ $doc->link_count }} | ||||||||||
| @endif | ||||||||||
| @else | ||||||||||
| - | ||||||||||
| @endif | ||||||||||
| </td> | ||||||||||
| <td> | ||||||||||
| <b> | ||||||||||
| @if (file_exists(storage_path('docs/').$doc->id)) | ||||||||||
| @if ($doc->hash == hash_file("sha256", storage_path('docs/').$doc->id)) | ||||||||||
| <font color="green">OK</font> | ||||||||||
| @if ($doc->file_exists) | ||||||||||
| @if ($doc->hash_valid) | ||||||||||
| <span style="color: green;">OK</span> | ||||||||||
| @else | ||||||||||
| <font color="red">HASH FAILS</font> | ||||||||||
| <span style="color: red">HASH FAILS</span> | ||||||||||
| @endif | ||||||||||
| @else | ||||||||||
| <font color="red">MISSING</font> | ||||||||||
| <span style="color: red">MISSING</span> | ||||||||||
| @endif | ||||||||||
| </b> | ||||||||||
| </td> | ||||||||||
|
|
@@ -50,4 +56,4 @@ | |||||||||
| </table> | ||||||||||
| </div> | ||||||||||
|
|
||||||||||
| @endsection | ||||||||||
| @endsection | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard
stat()return value before array access.If the file is deleted between the
file_exists()check andstat()call (TOCTOU race),stat()returnsfalse. Accessing$stats['nlink']onfalsewill produce a PHP warning.🛡️ Proposed fix
if ($fileExists) { $stats = stat($filePath); - $doc->link_count = $stats['nlink'] ?? 0; + if ($stats !== false) { + $doc->link_count = $stats['nlink'] ?? 0; + } $computedHash = hash_file('sha256', $filePath);🤖 Prompt for AI Agents