benih wrote in Tue Nov 28, 2023 1:57 pm:Can one selectively delete stuff (like terrain, osm data, etc) older than
x, like this?
- Code: Select all
TerraSync$ find . -type f -mtime -365 -delete
that could work but depending on where you run it, there are some things you do not want to delete, though... like do not delete the three files in the base of TerraSync...
if i were to work up some external "remove terrasync tiles older than X days" script, i would make a list of files in specific terrasync directories (eg: do NOT dig into the Airports and Models directories) that meet the criteria, work out which tile directory they are in, and then remove all the files in that directory... the last step would be to remove any empty directories... note that there will be dotted files in each directory, too... .dirhash and .dirindex... if a directory is being wiped clean, these files need to go, too, so the directory is really empty and can be removed... i mention these specifically because some tools cannot see dotted files without specific instructions...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
i had to laugh when i saw this pop up in today's run through the forum... i installed TerraMaster the other day because i was helping someone and i also wanted to see how my almost full load of terrasync looked and update it since it has been a couple of years... one of the first things i noticed was a band completely around the Earth at 17S latitude... "that's interesting," i thought... i kind of remembered seeing it some years back and thought it might have been a bug that's since been fixed and TS cleaned up...
to test this, i removed all of the ones at this latitude that were in the ocean because there can't be islands or objects all the way around the Earth in this one specific latitude, right? once they were removed, i exited TerraMaster, fired up FG with the UFO, and spawned in at some longitude and 16.5S latitude... then i proceeded to fly around the world at 90True or 270True... either one would keep me at 16.5S all the way around the Earth... when i completed the full circuit, i exited FG, fired up TerraMaster, and took another look... low and behold that entire line had returned! i was quite surprised...
now, i'm not sure how TM decides to draw a colored frame around the tiles... does the existence of the deepest tile directory cause it or must there also be an .stg? i don't know... i do still find some top level eXXXnXX directories with only .dirhash and .dirindex files in them... the .dirhash files shows the hash of the .dirindex file and the .dirindex file shows hashes and file sizes (i think) for txz files which do not exist... i'm thinking that TM isn't fully updated to the current scenery methodology... the last release of TM was back in 2021 during the time that the OSM stuff was being added and figured out how to store and update... i do remember that that's when the txz files were introduced...
in any case, while i was going through all of that, i decided to whip up a script to remove empty directories because i didn't want anything left of 17S that was not on actual terrain... the script is very similar to what is being asked here about removing files/tile directories that are older than X days...
the meat of my "remove empty files and directories" (bash) script follows...
- Code: Select all
#work only inside these six terrasync directories
for foo in Buildings Details Objects Pylons Roads Terrain
do
#find files first, then directories
for bar in f d
do
#build command line for test mode
CMD="find $HOME/myflightgear/TSScenery/$foo -empty -type $bar"
#if this is NOT a test, add the -delete command with -print to log everything being removed
if [[ "$MYTEST" = false ]] ; then
CMD="$CMD -delete -print"
fi
printf "\n\nExecuting: $CMD\n"
printf "################################################################################\n\n"
$CMD
printf "\n\n################################################################################\n"
done
done
while writing this response, i had a thought that maybe detecting the -mtime of only the directories should work, too... if the directory hasn't been modified in X days, it doesn't matter about the files inside it... just delete them, remove the directory, and go to the next one... the question, then, is what does FG and/or TerraMaster do when they process the .dirhash and .dirindex files and see the referenced directories do not exist... do they recreate them with .dirhash and .dirindex files in them? if so, then i guess we could leave them alone but it doesn't really matter since they don't consume that much space, really... i guess one could test this pretty easily by creating a new testing terrasync directory for FG and TerraMaster to use and then flying in a limited area to see what directories and files are created/downloaded... i would hope only the ones needed are created and not a bunch of empty ones containing only .dirhash and .dirindex... and yes, i know this script cannot remove directories that do only contain .dirhash and .dirindex since the directories are, technically, not empty...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."