ClassiCube / MCGalaxy

A Minecraft Classic / ClassiCube server software
GNU General Public License v3.0
168 stars 79 forks source link

Created time doesn't work on Unix #682

Open rdebath opened 2 years ago

rdebath commented 2 years ago

The created time doesn't exist on standard Unix filesystems, there's

The EXT4 filesystem does have a file created time, but it can only be accessed by the superuser.

A file created time is available on Windows, but this is still technically inaccurate as it doesn't say when the level was created, just when the file was last copied.

Please add a new field to the level properties to be populated when a level is created and suppress the display of the (wrong) time when the property doesn't exist or has a "null" value.

[09:37:26] About test3: Width=128 Height=128 Length=128
[09:37:26]   Physics are OFF, gun usage is disabled
[09:37:26]   Created 20m ago, last backup (24m ago): 14
[09:37:26]   BlockDB (Used for /b) is Enabled with 96468741 entries
[09:37:26]   Visitable by Guest+
[09:37:26]   Modifiable by Guest+
[09:37:26] Use /mi env test3 to see environment settings.

Finding the file created time on an EXT4 filesystem using debugfs and sudo.

xstat() {
  for target in "${@}"; do
    inode=$(ls -di "${target}" | cut -d ' ' -f 1)
    fs=$(df "${target}"  | tail -1 | awk '{print $1}')
    crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | 
    grep -oP 'crtime.*--\s*\K.*')
    printf "%s\t%s\n" "${crtime}" "${target}"
  done
}
UnknownShadow200 commented 2 years ago

Adding creation date to level properties file has been on private todo list for a while now (over four years), just haven't gotten around to implementing