Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dregad
Created June 19, 2018 14:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dregad/a8c27ef7a437ae60f5aa4aacdadaeed9 to your computer and use it in GitHub Desktop.
Save dregad/a8c27ef7a437ae60f5aa4aacdadaeed9 to your computer and use it in GitHub Desktop.
DokuWiki set timestamp to fix `(external edit)`
#!/bin/bash
# DokuWiki helper script to fix the pages's last modified time stamp
# to match the one recorded in the metadata.
# This fixes pages shown as 'last modified by (external edit)', e.g. after
# restoring the wiki from a backup without preserving the files' timestamp.
#
# Copyright (c) 2018 Damien Regad
#
# Revision history
# 2018-06-19 Created
# ----------------------------------------------------------------------------
# Change this to point to your dokuwiki's data directory
DW_DATA=~/dokuwiki/data
# ----------------------------------------------------------------------------
DW_PAGES=$DW_DATA/pages
DW_META=$DW_DATA/meta
# Process all pages in the wiki
find $DW_PAGES -type f -printf "%P\t%T@\n" |
while read file timestamp
do
# Remove file extension to get the page name with path
page=${file%.*}
# Page's history file - skip if it does not exist
history=$DW_META/$page.changes
[[ -e $history ]] || continue
# Get the most recent timestamp in history file
dw_time=$(tail -1 $history | cut -f1)
# Reset the timestamp if the file's is more recent
if [[ ${timestamp%.*} -gt $dw_time ]]
then
echo $page "- updating timestamp" $(date -Is --date="@$timestamp") "->" $(date -Is --date="@$dw_time")
touch --date="@$dw_time" $DW_PAGES/$file
fi
done
@franc00018
Copy link

Thanks, you saved me hours of trouble dealing with a 500 Error on the start page

@smartin77
Copy link

Thank you too! It helped me after data migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment