Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

franc00018 commented May 23, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.