Ignore buffer errors when the path is a directory

This would previously cause Atom to fail to launch if a buffer's
serialized path was now a directory on launch.
This commit is contained in:
Kevin Sawicki 2015-01-15 11:51:11 -08:00
parent 67fc2b9af5
commit 6ad8aa7e5c
2 changed files with 19 additions and 1 deletions

View File

@ -37,6 +37,19 @@ describe "Project", ->
deserializedProject.getBuffers()[0].destroy()
expect(deserializedProject.getBuffers().length).toBe 0
it "does not deserialize buffers when the path is a directory", ->
pathToOpen = path.join(temp.mkdirSync(), 'file.txt')
waitsForPromise ->
atom.project.open(pathToOpen)
runs ->
expect(atom.project.getBuffers().length).toBe 1
fs.mkdirSync(pathToOpen)
deserializedProject = atom.project.testSerialization()
expect(deserializedProject.getBuffers().length).toBe 0
describe "when an editor is saved and the project has no path", ->
it "sets the project's path to the saved file's parent directory", ->
tempFile = temp.openSync().path

View File

@ -66,7 +66,12 @@ class Project extends Model
buffers: _.compact(@buffers.map (buffer) -> buffer.serialize() if buffer.isRetained())
deserializeParams: (params) ->
params.buffers = params.buffers.map (bufferState) -> atom.deserializers.deserialize(bufferState)
params.buffers = _.compact params.buffers.map (bufferState) ->
try
atom.deserializers.deserialize(bufferState)
catch error
# Ignore buffers for files that are now folders
throw error unless error.code is 'EISDIR'
params