0

chrome.fileSystem.isRestorable is a new part of the chrome.fileSystem API and it saif if a file can be restored with its entry or not. I've made many tests but something is wrong, when I tried to do :

chrome.storage.local.get(
["recentFileId1"],
function(recent) {
  chrome.fileSystem.isRestorable(
    recent["recentFileId1"], 
    function (isRestorable){
      console.log(isRestorable);
    });
});

It returns me true, even if the file has been deleted of my computer. recentFileId1 seems like a real id (many numbers and the path at the end, for example FD158F2A41037D17440C025C1CA5FE08:question.txt) and the file's restoration works if the file is still on my computer. When I tried to restore the file with an id of a deleted file it just returns nothing, no error.

So I want to know : did I use this feature wrong or something? It can work if I try to restore and see what is restored (if it returns nothing the file has been deleted), but I don't want to use a hack if the API is available.

Thanks.

4

1 回答 1

2

该功能目前仅在 Chrome 的 dev 通道中可用,应该会在 31 版本中发布到稳定版。

您所描述的内容听起来像是一个错误,请在http://crbug.com提交。我们应该始终返回 true 或 false。在这种情况下,正确的行为应该是什么尚不清楚。

这个函数的目的是让应用知道它是否应该提供 UI 来让用户访问以前打开的文件。如果文件是可恢复的,这仅仅意味着应用程序仍然有权访问该文件。

我们保留限制文件何时可恢复的权利。例如,我们可能对可以恢复的文件数量有一个任意上限,或者几个月后访问可能会超时,或者我们可以让用户选择不让应用程序恢复任何文件。isRestorable 让您知道是否仍然可以访问以前打开的文件。

isRestorable 并非旨在提供有关文件仍然可以访问的信息。本地更改可能会影响这一点 - 例如,文件可能被删除或操作系统访问权限发生更改。它可能仍然存在,但由于对包含文件夹没有读取权限,因此对 chrome 和应用程序不可见。

想想最近的文档菜单。这可以显示已打开和已删除的文件。当应用程序恢复已删除的应用程序时,它将无法正常工作并向用户显示错误。此时,用户可能会去他们的回收站或 git checkout 并替换文件。

或者最近的文档菜单无法显示已删除的文件。

无论哪种方式,您的应用程序都不应该依赖 isRestorable 作为文件条目是否可以重新获得和成功使用的指示,您应该处理 restoreFile 而不是恢复文件并给出错误,并处理对有权限问题的文件的访问。

于 2013-09-19T02:34:16.510 回答