Skip to content

Conversation

@aitken85
Copy link
Collaborator

@aitken85 aitken85 commented Feb 12, 2025

Updates FileModel->delete() to also delete the physical file

Tests fail!

Sprout\Exceptions\FileUploadException: Failed to move uploaded file
/srv/sprout3/src/sprout/Models/FileModel.php:214

This is the FileModel::fromPath unable to move file. So something setup wrong in my tests, not a fault in the delete method, hopefully.

This PR is mostly to get the ball rolling with any fixes that maybe required, then approved.

@gwillz
Copy link
Collaborator

gwillz commented Feb 12, 2025

<3 the unit tests

Hey, when we get nested transactions merged we can even do cool stuff like this:

$this->getConnection()->withTransaction(function() {
   $this->delete();
   File::delete($this->filename);
});

Meaning the file is only deleted if the DB commit works. Or if the DB commit fails, the file isn't deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants