File incremental update for new version

This commit is contained in:
brunosimon
2016-08-11 21:57:07 +02:00
parent bdda23cc43
commit a73a484d2a
4 changed files with 37 additions and 21 deletions
+4
View File
@@ -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 )
}
+3 -5
View File
@@ -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
}