obsidian-api icon indicating copy to clipboard operation
obsidian-api copied to clipboard

is it possible to expose Stat for TFolder?

Open fyears opened this issue 4 years ago • 4 comments

Hi,

Currently a Stat property containing mtime and ctime is exposed for TFile, but the same info is not exposed for TFolder. It is possible to directly include this info insider TFolder?

Thanks!

fyears avatar Feb 21 '22 00:02 fyears

… and adaptor.stat(any_folder) also returns 0 mtime and ctime, is it possible to “fix” this as well? (if not intentionally designed)

Thank you so much!

fyears avatar Feb 21 '22 09:02 fyears

For stat, we currently intentionally return 0 for both but I guess it wouldn't hurt to return whatever the underlying OS gives us. Will ship this next patch.

For the actual stat property, I will look into this later as it's slightly more involved in the underlying code changes required to expose this.

lishid avatar Feb 22 '22 19:02 lishid

Hi, I find another bug today, but I think it's relevant to the current issue so I post the bug here.

On Android Obsidian insider 1.2.1 ,the stat() api returns unexpected result for folder with mtime and ctime being NaN instead of 0 or undefined or actual timestamps. (And also the size should be 0 instead of undefined.) Is it the expected behavior?

app.vault.adapter.stat('.obsidian').then(console.log)

// {type: "folder", ctime: NaN, mtime: NaN, size: undefined}

On the OS files app instead of Obsidian, I can see the actual last modified time of the folders, so at least the mtime should be available to some apps.

fyears avatar May 09 '22 16:05 fyears

Oops seems like they were omitted from the results, will fix next release.

lishid avatar May 11 '22 13:05 lishid

I think we'll leave it as it is for now - you can use stat() to get it, but it won't be available on the TFolder object.

lishid avatar Sep 23 '22 00:09 lishid