aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeshan Wanigasooriya <heshanmw@gmail.com>2009-06-18 01:50:22 +0000
committerHeshan Wanigasooriya <heshanmw@gmail.com>2009-06-18 01:50:22 +0000
commita2e889645f2438638b99572b956513745615cbc3 (patch)
treecaad99607d1b5f3380b048562395a27506430fe7
parent557a5b80f3f3ae6b3b7707ef7ecf1396071ab590 (diff)
downloadvideo-a2e889645f2438638b99572b956513745615cbc3.tar.gz
video-a2e889645f2438638b99572b956513745615cbc3.tar.bz2
#493742 by glen201: Replacing video does not remove previously converted video from filesystem
-rw-r--r--plugins/video_ffmpeg_helper/video_render.php5
-rw-r--r--video.module9
2 files changed, 10 insertions, 4 deletions
diff --git a/plugins/video_ffmpeg_helper/video_render.php b/plugins/video_ffmpeg_helper/video_render.php
index 0018d98..e4a6b6d 100644
--- a/plugins/video_ffmpeg_helper/video_render.php
+++ b/plugins/video_ffmpeg_helper/video_render.php
@@ -179,10 +179,15 @@ function _video_render_set_video_encoded_fid($nid, $vid, $encoded_fid) {
db_lock_table('video');
$node = db_fetch_object(db_query("SELECT serialized_data FROM {video} WHERE nid = %d AND vid = %d", $nid, $vid));
$node->serial_data = unserialize($node->serialized_data);
+ //GMM: save fid of previously encoded file
+ $old_fid = $node->serial_data['video_encoded_fid'];
$node->serial_data['video_encoded_fid'] = $encoded_fid;
$node->serialized_data = serialize($node->serial_data);
db_query("UPDATE {video} SET serialized_data = '%s' WHERE nid = %d AND vid = %d", $node->serialized_data, $nid, $vid);
db_unlock_tables();
+ // GMM: update status on previously encoded fid to 0 so drupal will delete
+ if($old_fid > 0)
+ db_query("UPDATE {files} SET status = %d WHERE fid = %d", 0, $old_fid);
}
diff --git a/video.module b/video.module
index dc67235..1a374fa 100644
--- a/video.module
+++ b/video.module
@@ -798,10 +798,11 @@ function video_update($node) {
else {
// set the required properties of the video node
video_presave($node);
- // kjh: make sure to save the encoded_fid
- if ($node->new_video_upload_file_fid == 0 && $node->video_encoded_fid) {
- $node->serial_data['video_encoded_fid'] = $node->video_encoded_fid;
- }
+
+ // GMM: make sure to save the encoded_fid
+ if (!isset($node->serial_data['video_encoded_fid']) && $node->video_encoded_fid) {
+ $node->serial_data['video_encoded_fid'] = $node->video_encoded_fid;
+ }
$node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database.