mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-06-04 19:35:58 +08:00
.devcontainer
.gitea
.github
assets
build
cmd
contrib
custom
docker
docs
models
modules
actions
activitypub
analyze
assetfs
auth
avatar
base
cache
charset
container
context
contexttest
csv
doctor
emoji
eventsource
generate
git
gitgraph
graceful
hcaptcha
highlight
hostmatcher
html
httpcache
httplib
indexer
issue
json
label
lfs
log
markup
mcaptcha
metrics
migration
nosql
options
packages
paginator
pprof
private
process
proxy
proxyprotocol
public
queue
recaptcha
references
regexplru
repository
secret
session
setting
sitemap
ssh
storage
structs
svg
sync
system
templates
test
testlogger
timeutil
datetime.go
datetime_test.go
executable.go
since.go
since_test.go
timestamp.go
timestampnano.go
translation
turnstile
typesniffer
updatechecker
upload
uri
user
util
validation
web
webhook
options
public
routers
services
snap
templates
tests
web_src
.air.toml
.changelog.yml
.dockerignore
.drone.yml
.editorconfig
.eslintrc.yaml
.gitattributes
.gitignore
.gitpod.yml
.golangci.yml
.ignore
.markdownlint.yaml
.npmrc
.spectral.yaml
.stylelintrc.yaml
.yamllint.yaml
BSDmakefile
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
DCO
Dockerfile
Dockerfile.rootless
LICENSE
MAINTAINERS
Makefile
README.md
README_ZH.md
SECURITY.md
build.go
go.mod
go.sum
main.go
package-lock.json
package.json
playwright.config.js
poetry.lock
poetry.toml
pyproject.toml
vitest.config.js
webpack.config.js

Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
51 lines
929 B
Go
51 lines
929 B
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package timeutil
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"sync"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
|
)
|
|
|
|
var (
|
|
executablModTime = time.Now()
|
|
executablModTimeOnce sync.Once
|
|
)
|
|
|
|
// GetExecutableModTime get executable file modified time of current process.
|
|
func GetExecutableModTime() time.Time {
|
|
executablModTimeOnce.Do(func() {
|
|
exePath, err := os.Executable()
|
|
if err != nil {
|
|
log.Error("os.Executable: %v", err)
|
|
return
|
|
}
|
|
|
|
exePath, err = filepath.Abs(exePath)
|
|
if err != nil {
|
|
log.Error("filepath.Abs: %v", err)
|
|
return
|
|
}
|
|
|
|
exePath, err = filepath.EvalSymlinks(exePath)
|
|
if err != nil {
|
|
log.Error("filepath.EvalSymlinks: %v", err)
|
|
return
|
|
}
|
|
|
|
st, err := os.Stat(exePath)
|
|
if err != nil {
|
|
log.Error("os.Stat: %v", err)
|
|
return
|
|
}
|
|
|
|
executablModTime = st.ModTime()
|
|
})
|
|
return executablModTime
|
|
}
|