diff options
| author | Shulhan <ms@kilabit.info> | 2024-12-23 02:42:06 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-01-07 00:13:55 +0700 |
| commit | b686ea0a41b7af68d4d86ff3cc2c3068ebb88b66 (patch) | |
| tree | b8725c3c2e2461e2b0542c76880d385ee5aa6741 /file_markup.go | |
| parent | ff338f853eb7537230c84ccc06feae3b63859877 (diff) | |
| download | ciigo-b686ea0a41b7af68d4d86ff3cc2c3068ebb88b66.tar.xz | |
all: refactoring to use [watchfs/v2]
The [watchfs/v2] bring new enhancements that watching only single file
instead of all markup files for changes.
This minimize number of goroutine calling os.Stat on each markup
files being watched on directory.
Diffstat (limited to 'file_markup.go')
| -rw-r--r-- | file_markup.go | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/file_markup.go b/file_markup.go index b2d051f..95785bb 100644 --- a/file_markup.go +++ b/file_markup.go @@ -20,7 +20,6 @@ const ( type FileMarkup struct { info os.FileInfo // info contains FileInfo of markup file. - basePath string // Full path to file without markup extension. path string // Full path to markup file. pathHTML string // path to HTML file. @@ -30,11 +29,7 @@ type FileMarkup struct { // NewFileMarkup create new FileMarkup instance form file in "filePath". // The "fi" option is optional, if its nil it will Stat-ed manually. func NewFileMarkup(filePath string, fi os.FileInfo) (fmarkup *FileMarkup, err error) { - var ( - logp = `NewFileMarkup` - - ext string - ) + var logp = `NewFileMarkup` if len(filePath) == 0 { return nil, fmt.Errorf(`%s: empty path`, logp) @@ -46,17 +41,16 @@ func NewFileMarkup(filePath string, fi os.FileInfo) (fmarkup *FileMarkup, err er } } - ext = strings.ToLower(filepath.Ext(filePath)) + var ext = strings.ToLower(filepath.Ext(filePath)) + var basePath = strings.TrimSuffix(filePath, ext) fmarkup = &FileMarkup{ - path: filePath, info: fi, - basePath: strings.TrimSuffix(filePath, ext), + path: filePath, + pathHTML: basePath + `.html`, kind: markupKind(ext), } - fmarkup.pathHTML = fmarkup.basePath + `.html` - return fmarkup, nil } |
