It would be useful to have an option for pm-update/pm-updatecode to remove the existing module/theme files before extracting the new ones.
- Many modules go through file name changes and can leave stray files lying around that can either just a) confuse the site maintainer or, worse yet, lead to bugs in the site.
- On the flip side, sometimes dependencies are copied within the module's directory structure and would cause the module to break were they to suddenly disappear, e.g. jQuery_UI.
- Lastly, because many revision management systems leave system files within the directory structure, care has to be made to not accidentally delete the wrong files.
So what I propose is an option, --remove-files
, that would remove all files within the directory with the exclusion of common known files, e.g. (pseudocode):
$count = 1;
while (system("rm -f {modulepath}" . str_repeat('/*', $count))) {
$count++;
}
The above code works because the '-f' flag to the UNIX 'rm' command forces files to be deleted but does not descent into directories, and because using the '*' file selector ignores files which start with a period, e.g. ".svn", ".git", etc. It does open a problem with CVS as those directories would have their files removed, so obviously the code would probably work better in PHP with some proper filtering of the directory tree prior to file deletion.
Icing on the cake would be another option named --dont-remove which accepted a list of filenames/paths which were not removed, e.g. to account for unusual revision management tool system files.
Comments
Comment #1
ChrisRut CreditAttribution: ChrisRut commented:subscribe:
Comment #2
deverman CreditAttribution: deverman commentedYes this is needed to safely upgrade. Subscribe.
Comment #3
Chris CharltonFrom what I can tell it seems Drush has always moved out the entire folder before exchanging it with the new set. Maybe on SVN/CVS update it may not be the case.
Comment #4
deverman CreditAttribution: deverman commentedNormally we issue an svn delete then a commit and then download the module then svn add and then svn commit.
Comment #5
DamienMcKenna@deverman: if you svn-delete the files first you're needlessly complicating the ability to see which files have changed from version to version.
Comment #6
deverman CreditAttribution: deverman commentedok well...how do you recommend ensuring that there are not straggling files there from old modules that can muck up things?
Comment #7
Chris CharltonAn CVS/SVN update would (and should) be removing the files for you.
Comment #8
deverman CreditAttribution: deverman commentedI am confused in comment #7 the whole point of this issue is that this doesn't work properly when using the drush commands.
Comment #9
kirie CreditAttribution: kirie commented+1 subscribe
Comment #10
jonhattanupdatecode move projects to backup directory and download in /tmp since #826720: "--drupal-project-rename" doesn't seem to work. Same for dl.
To close the cicle, some work is still needed in #940688: updatecode: --version-control=backup stop updatecode --package-handler=cvs to use cvs update and force always a checkout..
Comment #12
webservant316 CreditAttribution: webservant316 commentedif the --no-backup option is used then drush does not remove the existing files. seems like it should in that case as well.
Comment #13
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis issue was marked
closed (won't fix)
because Drush has moved to Github.If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to
closed (duplicate)
.Please ask support questions on Drupal Answers.