DokuWiki

It's better when it's simple

User Tools

Site Tools


install:unused_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
install:unused_files [2015-02-25 19:22] – Shorten Python script and make it Python3 compatible 67.241.151.78install:unused_files [2023-02-28 13:41] (current) – Link to new dokuwiki repo saggi
Line 1: Line 1:
-===== Removing Unused Files =====+====== Removing Unused Files ======
  
-When a new DokuWiki version is released, some of the files that were needed previously may become obsolete. Keeping these files is harmless usually but they might pose a security risk or break installations later, so we recommend to delete them.+When a new DokuWiki version is released, some of the files that were needed previously may become obsolete. 
 + 
 +Keeping the files may cause the following issues: 
 + 
 +  * Misleading error messages related to outdated plugins. 
 +  * They pose a security risk
 +  * They could break later installations. 
 + 
 +So we recommend to delete them.
  
 A list of all files that were removed in recent releases can be found in ''data/deleted.files''. You should check if they still exist in your install. If they do, delete them. A list of all files that were removed in recent releases can be found in ''data/deleted.files''. You should check if they still exist in your install. If they do, delete them.
  
-You can also see the current list at https://github.com/splitbrain/dokuwiki/raw/stable/data/deleted.files+You can also see the current list at https://github.com/dokuwiki/dokuwiki/raw/stable/data/deleted.files
  
-==== Using RemoveOld Plugin ====+:!: Important: The list of files is case-sensitive. On case-insensitive file systems((Case-insensitive file systems are, under some circumstances: Windows and macOS)) the scripts below may delete too much!
  
-To remove old files from DokuWiki's Admin menu you can also use the [[plugin:RemoveOld]] plugin+===== Using a Plugin ===== 
-==== Using a Script ====+ 
 +When upgrading your wiki using the [[plugin:upgrade|upgrade Plugin]], the plugin will take care of removing the deleted files automatically for you
 + 
 +Alternatively the [[plugin:removeold|removeold Plugin]] can be used. 
 + 
 +===== Using a Script =====
  
 People with shell access to their server can use a script to automatically delete all old files. People with shell access to their server can use a script to automatically delete all old files.
  
-=== Linux Shell ===+==== Linux Shell ====
  
 This simple line should work on any Linux system This simple line should work on any Linux system
Line 22: Line 35:
 </code> </code>
  
-=== *nix Shell ===+==== *nix Shell ====
  
 Some systems may not support the "rm -d" option for directory removal. In that case, you have to use recursive removal (just be sure to double-check that the file list does not include any paths that will delete too much): Some systems may not support the "rm -d" option for directory removal. In that case, you have to use recursive removal (just be sure to double-check that the file list does not include any paths that will delete too much):
Line 30: Line 43:
 </code> </code>
  
-=== Python Script ===+==== Python Script ====
  
 Here's a Python script that will also print the files deleted Here's a Python script that will also print the files deleted
Line 48: Line 61:
 </code> </code>
  
-=== Ruby Script ===+Here's an alternative Python script that is case sensitive and will also delete directories included in the list 
 +<code python> 
 +import os 
 +import shutil 
 + 
 +def exists_casesensitive(path): 
 +    if not os.path.exists(path): 
 +        return False 
 +    directory, filename = os.path.split(path) 
 +    return filename in os.listdir(directory) 
 + 
 +with open("./data/deleted.files") as file: 
 +    for line in file: 
 +        line = line.strip() 
 +        if line and not line.startswith('#'): 
 +            path = line.rstrip(os.linesep) 
 +            if exists_casesensitive(path): 
 +                if os.path.isdir(path): 
 +                    shutil.rmtree(path) 
 +                    print('Directory removed =>  ' + path) 
 +                else: 
 +                    os.remove(path) 
 +                    print('File removed =>  ' + path) 
 +            else: 
 +                #print('File not found => ' + path) 
 +                pass 
 +</code> 
 + 
 +==== Ruby Script ====
  
 Here's a Ruby script doing the same Here's a Ruby script doing the same
Line 61: Line 102:
 </code>  </code> 
  
-=== PHP Script ===+==== PHP Script ====
  
 The same for PHP: The same for PHP:
Line 84: Line 125:
 </code> </code>
  
-=== Powershell Script ===+==== Powershell Script ====
  
 Here's a one-line powershell script doing the same Here's a one-line powershell script doing the same
Line 92: Line 133:
 </code> </code>
  
-=== CMD Script ===+==== CMD Script ====
  
-Here's a one-line Windows's CMD script doing the same+Here's a one-line Windows's CMD script doing the same, although you may need to first reverse all the slashes in 'deleted.files' for the filenames to be accepted.
  
 <code> <code>
 for /F %i in ('findstr /R /V /C:"^#" /C:"^$" data\deleted.files') do del "%i" for /F %i in ('findstr /R /V /C:"^#" /C:"^$" data\deleted.files') do del "%i"
 </code> </code>
install/unused_files.1424888566.txt.gz · Last modified: 2015-02-25 19:22 by 67.241.151.78

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki