News:

Dear forum visitors, if the support forum is not available, please try again a few minutes later. Thanks!

Main Menu
Support-Forum

Batch move not actually moving files - [Fixed in 3.9.8]

Started by dr236, 17.12.2020 19:34:02

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dr236

Hello

(For jd3.9.7.2) The "Batch Move" on the backend doesn't seem to be moving the files to the target folder (the category ids for the downloads are being changed ok).

In administrator/components/com_jdownloads/models/download.php, method batchMove, there doesn't seem to be any code to move the files.

I assume batchMove _should_ be moving files (as it used to). I've applied an emergency patch (basically copying code from batchCopy), but haven't tested it carefully:


diff --git a/htdocs/administrator/components/com_jdownloads/models/download.php b/htdocs/administrator/components/com_jdownloads/models/download.php
index c66604df..18fc75fd 100644
--- a/htdocs/administrator/components/com_jdownloads/models/download.php
+++ b/htdocs/administrator/components/com_jdownloads/models/download.php
@@ -886,6 +886,14 @@ class jdownloadsModelDownload extends JModelAdmin
                     return false;
                 }
             }
+
+            // Build the file path from the Downloads target category
+            if ($categoryTable->cat_dir_parent != ''){
+                $target_path = $categoryTable->cat_dir_parent.'/'.$categoryTable->cat_dir;
+            } else {
+                $target_path = $categoryTable->cat_dir;
+            }
+
         }

         if (empty($categoryId)) {
@@ -923,6 +931,50 @@ class jdownloadsModelDownload extends JModelAdmin
                 }
             }

+            // Move file
+            $source_path = '';
+           
+            if ($categoryId > 1 && $table->url_download != ''){
+                $copy_filename       = $table->url_download;
+                $source_cat_id       = $table->catid;
+                $target_cat_id       = $categoryId;
+               
+                // We must only move when we have a different cat id.
+                if ($source_cat_id != $target_cat_id){
+         
+                    // Get the data from the source category
+                    $sourceCategoryTable = JTable::getInstance('category', 'jdownloadsTable');
+                    if (!$sourceCategoryTable->load($source_cat_id)){
+                        if ($error = $sourceCategoryTable->getError()){
+                            // Fatal error
+                            $this->setError($error);
+                            return false;
+                        } else {
+                            // Category not found
+                            $this->setError(JText::_('COM_JDOWNLOADS_BATCH_MOVE_ROW_NOT_FOUND'));
+                            return false;
+                        }
+                    }
+                   
+                    // Build the file path from the Downloads source category
+                    if ($sourceCategoryTable->cat_dir_parent != ''){
+                        $source_path = $sourceCategoryTable->cat_dir_parent.'/'.$sourceCategoryTable->cat_dir.'/'.$copy_filename;
+                    } else {
+                        $source_path = $sourceCategoryTable->cat_dir.'/'.$copy_filename;
+                    }
+                   
+                    if ($source_path && $target_path){
+                        if (!JFile::exists($params->get('files_uploaddir') . '/'. $source_path)){
+                            $this->setError(JText::sprintf('COM_JDOWNLOADS_BATCH_CANNOT_FIND_COPY_FILE', $source_path));
+                        }
+
+                        if (!JFile::move($params->get('files_uploaddir') . '/' . $source_path, $params->get('files_uploaddir') . '/' . $target_path.'/'.$copy_filename)){
+                            $this->setError(JText::sprintf('COM_JDOWNLOADS_BATCH_CANNOT_COPY_FILES', $source_path));
+                        }
+                    }
+                }   
+            }   
+
             // Set the new category ID
             $table->catid = $categoryId;


Thanks, David
  •  

ColinM

DavidI confirm that the batch move does not move the actual files as it should do!! :(   It does create what appears to be Downloads in the target category.

For refererence a simple recovery is to delete the apparently moved Downloads from the target directory.  Then use the control panel to check the Download area for new files.  The missing files are still in the original directory so Downloads will be recreated.  This however will loose any other information in the original Download.
Colin





Colin M
  •  

Arno

Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

Arno

Hi,
I hope I could fix it. Please test the unzipped file below and copy it to your jdownloads admin subfolder /models. Overwrite the old file.
Please post here your result. Thanks.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

dr236

That looks ok, now. Thank you.

David
  •  

ColinM

Colin M
  •