Skip to content

Commit

Permalink
Fix cache loading errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Sep 24, 2023
1 parent d62d6d6 commit 59d74b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions autoload/dpp/min.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function dpp#min#_init() abort
endfunction
function! dpp#min#_load_cache_raw(vimrcs=[]) abort
let g:dpp#_vimrcs = a:vimrcs
const cache = g:dpp#_base_path .. '/cache_' .. g:dpp#_progname
const cache = printf('%s/cache_%s.vim', g:dpp#_base_path, g:dpp#_progname)
const time = cache->getftime()
if !(g:dpp#_vimrcs->copy()
\ ->map({ _, val -> getftime(expand(val)) })
Expand All @@ -33,7 +33,7 @@ function! dpp#min#load_state(path) abort
if g:dpp#_is_sudo | return 1 | endif
let g:dpp#_base_path = a:path->expand()

const state = g:dpp#_base_path .. '/state_' .. g:dpp#_progname .. '.vim'
const state = printf('%s/state_%s.vim', g:dpp#_base_path, g:dpp#_progname)
if !(state->filereadable()) | return 1 | endif
try
execute 'source' state->fnameescape()
Expand Down
17 changes: 8 additions & 9 deletions denops/dpp/dpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export class Dpp {
recordPlugins[plugin.name] = initPlugin(plugin, basePath);
}

console.log(recordPlugins);

if (!await isDirectory(basePath)) {
await Deno.mkdir(basePath, { recursive: true });
}
Expand All @@ -80,7 +78,6 @@ export class Dpp {

// Get runtimepath
const dppRuntimepath = `${basePath}/.dpp`;
console.log(dppRuntimepath);
if (!await isDirectory(dppRuntimepath)) {
await Deno.mkdir(dppRuntimepath, { recursive: true });
}
Expand Down Expand Up @@ -138,9 +135,9 @@ export class Dpp {
const cacheVersion = await vars.g.get(denops, "dpp#_cache_version");
const initRuntimepath = await vars.g.get(denops, "dpp#_init_runtimepath");
const stateLines = [
`if g:dpp#_cache_version !=# ${cacheVersion} || ` +
`g:dpp#_init_runtimepath !=# '${initRuntimepath}' | ` +
" | throw ''Cache loading error'' | endif",
`if g:dpp#_cache_version !=# ${cacheVersion} ` +
`|| g:dpp#_init_runtimepath !=# '${initRuntimepath}' | ` +
"throw 'Cache loading error' | endif",
"let [s:plugins, s:ftplugin] = dpp#min#_load_cache_raw()",
"if s:plugins->empty() | throw 'Cache loading error' | endif",
"let g:dpp#_plugins = s:plugins",
Expand All @@ -149,17 +146,19 @@ export class Dpp {
`let &runtimepath = '${newRuntimepath}'`,
];

const stateFile = `${basePath}/state_${progname}`;
const stateFile = `${basePath}/state_${progname}.vim`;
console.log(stateFile);
await Deno.writeTextFile(stateFile, stateLines.join("\n"));

const cacheFile = `${basePath}/cache_${progname}`;
const cacheFile = `${basePath}/cache_${progname}.vim`;
const cacheLines = [
JSON.stringify([plugins, {}]),
];
console.log(cacheFile);
await Deno.writeTextFile(cacheFile, cacheLines.join("\n"));

console.log(stateLines);
console.log(cacheLines);
//console.log(cacheLines);
//console.log(rtps);
}

Expand Down

0 comments on commit 59d74b7

Please sign in to comment.