File incremental update for new version
This commit is contained in:
@@ -17,6 +17,7 @@ class File
|
||||
this.path.full = this.path.directory + '/' + this.name
|
||||
this.path.parts = this.path.full.split( paths.separator )
|
||||
this.versions = []
|
||||
this.socket = _options.socket
|
||||
|
||||
// Create first version
|
||||
if( typeof _options.content !== 'undefined' )
|
||||
@@ -33,6 +34,9 @@ class File
|
||||
version.content = content
|
||||
version.diff = last_version ? diff.diffChars( last_version.content, version.content ) : false
|
||||
|
||||
// Emit
|
||||
this.socket.emit( 'create_version', { file: this.path.full, version: version } )
|
||||
|
||||
// Save
|
||||
this.versions.push( version )
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ class Files
|
||||
file = new File( {
|
||||
name : parsed_path.base,
|
||||
path : parsed_path.dir,
|
||||
content: _content
|
||||
content: _content,
|
||||
socket : this.socket
|
||||
} )
|
||||
|
||||
// Save
|
||||
@@ -70,7 +71,7 @@ class Files
|
||||
return false
|
||||
}
|
||||
|
||||
update( _path, _content )
|
||||
create_version( _path, _content )
|
||||
{
|
||||
// Set up
|
||||
let normalized_path = paths.normalize( _path )
|
||||
@@ -81,9 +82,6 @@ class Files
|
||||
// Create version
|
||||
file.create_version( _content )
|
||||
|
||||
// Emit
|
||||
this.socket.emit( 'update_file', file.describe() )
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user