1 回答

TA貢獻(xiàn)1883條經(jīng)驗(yàn) 獲得超3個(gè)贊
PyFilesystem 作者在這里。簡(jiǎn)短的回答是否定的,在內(nèi)存文件系統(tǒng)的情況下,一旦關(guān)閉 FS 對(duì)象,內(nèi)存就會(huì)被丟棄。只有底層存儲(chǔ)機(jī)制是持久的,文件系統(tǒng)才會(huì)持久。
稍微長(zhǎng)一點(diǎn)的答案是您可以使用 TempFS 的子目錄來(lái)創(chuàng)建持久文件系統(tǒng)。
# Create a temporary filesystem at module scope
temp_fs = open_fs('temp://')
# Acquire new persistent temporary directory
# (this is just a path you can pass to open_fs)
# If you open this multiple times, the data will persist
new_dir = temp_fs.makedir('foo').getsyspath()
# Close temporary filesystem, to delete all directories
temp_fs.close()
這應(yīng)該給你你描述的語(yǔ)義。
如果您正在使用的項(xiàng)目正在使用 FS url 打開(kāi)和關(guān)閉文件系統(tǒng),并且仍然期望數(shù)據(jù)在那里,那么它將與不受持久存儲(chǔ)支持的文件系統(tǒng)中斷。也許您可以向作者建議,只要需要,他們就可以保留 FS 對(duì)象,這是我通常建議的。
添加回答
舉報(bào)