Created
June 19, 2018 14:13
-
-
Save dregad/a8c27ef7a437ae60f5aa4aacdadaeed9 to your computer and use it in GitHub Desktop.
DokuWiki set timestamp to fix `(external edit)`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you too! It helped me after data migration.