mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
fix: make the path for file_lock unless it exists (#205)
This commit is contained in:
parent
865f51a611
commit
8783a062f7
@ -1,3 +1,4 @@
|
|||||||
|
local Path = require "plenary.path" --[[@as FrecencyPlenaryPath]]
|
||||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||||
local log = require "plenary.log"
|
local log = require "plenary.log"
|
||||||
|
|
||||||
@ -30,6 +31,13 @@ function FileLock:get()
|
|||||||
local err, fd
|
local err, fd
|
||||||
while true do
|
while true do
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
local dir = Path.new(self.filename):parent()
|
||||||
|
if not dir:exists() then
|
||||||
|
-- TODO: make this call be async
|
||||||
|
log.debug(("file_lock get(): mkdir parent: %s"):format(dir.filename))
|
||||||
|
---@diagnostic disable-next-line: undefined-field
|
||||||
|
dir:mkdir { parents = true }
|
||||||
|
end
|
||||||
err, fd = async.uv.fs_open(self.filename, "wx", tonumber("600", 8))
|
err, fd = async.uv.fs_open(self.filename, "wx", tonumber("600", 8))
|
||||||
if not err then
|
if not err then
|
||||||
break
|
break
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
---@field filename string
|
---@field filename string
|
||||||
---@field joinpath fun(self: FrecencyPlenaryPath, ...): FrecencyPlenaryPath
|
---@field joinpath fun(self: FrecencyPlenaryPath, ...): FrecencyPlenaryPath
|
||||||
---@field make_relative fun(self: FrecencyPlenaryPath, cwd: string): string
|
---@field make_relative fun(self: FrecencyPlenaryPath, cwd: string): string
|
||||||
---@field parent FrecencyPlenaryPath
|
---@field parent fun(self: FrecencyPlenaryPath): FrecencyPlenaryPath
|
||||||
---@field path { sep: string }
|
---@field path { sep: string }
|
||||||
---@field rm fun(self: FrecencyPlenaryPath, opts?: { recursive: boolean }): nil
|
---@field rm fun(self: FrecencyPlenaryPath, opts?: { recursive: boolean }): nil
|
||||||
---@field touch fun(self: FrecencyPlenaryPath, opts?: { parents: boolean }): nil
|
---@field touch fun(self: FrecencyPlenaryPath, opts?: { parents: boolean }): nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user