gun-file icon indicating copy to clipboard operation
gun-file copied to clipboard

gun-file generates wrong .json ( Gun 0.9 )

Open Stefdv opened this issue 8 years ago • 5 comments

There's a problem with how gun-file writes its json

Setup (http.js):

var Gun = require('gun/gun');
Gun.serve = require('gun/lib/serve');
require('gun/lib/ws');
require('gun-file');


....
/* server setup */
....
var gun = Gun({
  'file-name' : 'data.json',  
  'file-pretty' : true, 				
   web: server
});
server.listen(port);
console.log('Server started on port ' + port + ' with /gun');

var test = gun.get('testSoul').put({x:'x value'})
test.val(node => {
        console.log('Gun.node.is(node) :',Gun.node.is(node) )
	console.log(JSON.stringify(node))
	console.log('node.x : ',node.x)
	console.log('node._ : ',node._)
})
/* output */
Gun.node.is(node) : false
{"testSoul":{"_":{"#":"testSoul",">":{"x":1512422015790}},"x":"x value"}}
node.x :  undefined
node._ :  undefined

If i remove 'gun-file'

var Gun = require('gun/gun');
Gun.serve = require('gun/lib/serve');
require('gun/lib/ws');
//require('gun-file');

....
/* server setup */
....
var gun = Gun({
	web: server
});
server.listen(port);
console.log('Server started on port ' + port + ' with /gun');
var test = gun.get('testSoul').put({x:'x value'})
test.val(node => {
        console.log('Gun.node.is(node) :',Gun.node.is(node) )
	console.log(JSON.stringify(node))
	console.log('node.x : ',node.x)
	console.log('node._ : ',node._)
})

My output is correct

Gun.node.is(node) : true
{"_":{"#":"testSoul",">":{"x":1512422851745}},"x":"x value"}
node.x :  x value
node._ :  { '#': 'testSoul', '>': { x: 1512422851745 } }

Stefdv avatar Dec 04 '17 21:12 Stefdv

After removing web:server and server.listen I get the same output you do... with or without gun-file.

M:\javascript\gun-file\test>node test_2.js
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions ta
gged with 'gun'!
0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and t
ransport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.
Server started on port 0 with /gun
Gun.node.is(node) : true
{"_":{"#":"testSoul",">":{"x":1512428747643}},"x":"x value"}
node.x :  x value
node._ :  { '#': 'testSoul', '>': { x: 1512428747643 } }

M:\javascript\gun-file\test>node test_2.js
Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions ta
gged with 'gun'!
0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and t
ransport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.
Server started on port 0 with /gun
Gun.node.is(node) : true
{"_":{"#":"testSoul",">":{"x":1512428758585}},"x":"x value"}
node.x :  x value
node._ :  { '#': 'testSoul', '>': { x: 1512428758585 } }

d3x0r avatar Dec 04 '17 23:12 d3x0r

Lol... Yes, with Gun 0.8 it does work :) I'm using gun-file since you published it. So maybe i should have been clear that i'm using Gun 0.9 ;p Please try it with Gun 0.9.

Stefdv avatar Dec 05 '17 08:12 Stefdv

Hmm I thought I had updated gun. You're right. Will get back to this soon.

d3x0r avatar Dec 05 '17 09:12 d3x0r

Fixed; was generating input event on wrong object. pushed and published.

d3x0r avatar Dec 07 '17 08:12 d3x0r

this was resolved for you?

d3x0r avatar Jul 05 '18 02:07 d3x0r