Skip to content

Commit

Permalink
added more efficient fetching of converted file
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhunt committed Apr 5, 2024
1 parent df4c2da commit 36965b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Change List
=========
Version 3.1.76 (Build 2024040501)
- Delayed adhoc task temp file download until after we have fetched placeholder file records

Version 3.1.75 (Build 2024040500)
- Fixed missing ad-hoc task duplicate detection

Expand Down
26 changes: 14 additions & 12 deletions classes/task/adhoc_s3_move.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,21 @@ public function execute() {

//get passed in data we need to perform conversion
$cd = $this->get_custom_data();
$awsremote = new \filter_poodll\awsremote();

//fetch any file records, that currently hold the placeholder file
//usually just one, but occasionally there will be two (1 in draft, and 1 in perm)
//if there are none. The user may just not have saved yet
$placeholder_file_recs = \filter_poodll\poodlltools::fetch_placeholder_file_record($cd->mediatype, $cd->filename);
if (!$placeholder_file_recs) {
$giveup = false;
$message = 'could not find placeholder file:' . $cd->filename;
$this->handle_s3_error(self::LOG_PLACEHOLDER_NOT_FOUND, $message, $cd, $giveup, $trace);
return;
}

//fetch the file
try {
$awsremote = new \filter_poodll\awsremote();
$ret = $awsremote->fetch_s3_converted_file($cd->mediatype, $cd->infilename, $cd->outfilename, $cd->filename);

} catch (\Exception $e) {
Expand Down Expand Up @@ -79,17 +91,7 @@ public function execute() {
$tempfilepath = $ret;
}

//fetch any file records, that currently hold the placeholder file
//usually just one, but occasionally there will be two (1 in draft, and 1 in perm)
$placeholder_file_recs = \filter_poodll\poodlltools::fetch_placeholder_file_record($cd->mediatype, $cd->filename);
//do the replace, if it succeeds yay. If it fails ... try again. The user may just not have saved yet
if (!$placeholder_file_recs) {
$giveup = false;
$message = 'could not find placeholder file:' . $cd->filename;
$this->handle_s3_error(self::LOG_PLACEHOLDER_NOT_FOUND, $message, $cd, $giveup, $trace);
return;
}

//do the replace
try {
foreach ($placeholder_file_recs as $file_rec) {
\filter_poodll\poodlltools::replace_placeholderfile_in_moodle($cd->filerecord, $file_rec, $tempfilepath);
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024040500;
$plugin->version = 2024040501;
$plugin->requires = 2016052300;//moodle 3.1.0
$plugin->component = 'filter_poodll';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '3.1.75 (Build 2024040500)';
$plugin->release = '3.1.76 (Build 2024040501)';

0 comments on commit 36965b6

Please sign in to comment.