Dependency Graph

Dependency Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

IDProjectCategoryView StatusLast Update
0037426mantisbtattachmentspublic2026-09-28 08:21
Reporterricardoalonsos Assigned Tocommunity  
PrioritynormalSeveritymajorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version2.28.4 
Summary0037426: Moving an issue between projects fails or silently skips its attachments when the source project's file path has changed
Description

file_move_bug_attachments() derives each attachment's source location from
the source project's current file_path, ignoring the folder column that
records where the file was actually written. The function also writes
folder at the end of each move, so it disagrees with itself: it maintains a
column it never reads.

project_update() lets an administrator repoint a project's file_path
without moving the attachments already on disk. From that point on, moving an
issue out of that project looks for its attachments in a directory that never
held them, with two distinct outcomes:

  1. Normally, rename() and then copy() both fail, and the move aborts with
    ERROR_FILE_MOVE_FAILED ("Unable to move file to ..."). The issue cannot be
    moved at all.

  2. If the two projects' configured paths happen to be equal, the early
    if( $t_path_from == $t_path_to ) return; skips the move entirely. The
    attachment is left in its old directory and folder still points there,
    even though the issue now belongs to a project whose uploads live elsewhere.

That early return is wrong in principle as well as in this case: it compares
two projects' configuration, which says nothing about where any particular
attachment actually is.

Steps To Reproduce

With $g_file_upload_method = DISK:

  1. Create project A with file_path = /mnt/a/ and project B with
    file_path = /mnt/b/.
  2. Attach a file to an issue in project A. It is written to /mnt/a/ and
    folder records /mnt/a/.
  3. Edit project A and change its file path to /mnt/c/ (any existing writable
    directory). Existing attachments are not moved, as expected.
  4. Move the issue to project B.

Result: the move fails with "Unable to move file to /mnt/b/<diskfile>".

For the second variant, at step 3 set both projects' file paths to the same
new directory, then move the issue: the move reports success, but the file is
still in /mnt/a/ and folder still says /mnt/a/.

Additional Information

This is the same root cause as the reader-side problem reported separately
(folder being written but not read), but in a different function and with a
different symptom, so it is filed on its own.

TagsNo tags attached.

Relationships

related to 0037424 acknowledgedcommunity Attachments are orphaned on disk when a project's file path is changed 

Activities