mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-06 23:26:25 +03:00
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:
parent
67fc2b9af5
commit
6ad8aa7e5c
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user