<commit_before>var fs = Npm.require('fs');
var path = Npm.require( 'path' );
var pathAdjustment = Assets.getText("path.json");
console.log(pathAdjustment);
var __ROOT_APP_PATH__ = fs.realpathSync(pathAdjustment); //current path
var pastesPath = path.join(__ROOT_APP_PATH__, "/private/pastes/");

console.log(pastesPath);
var s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789£$&^"; //allowed char for paste's name
var pastesNameLenght = 7;



if(!fs.existsSync(pastesPath)){
	fs.mkdirSync(pastesPath, 0766, function(err){
		if(err){ 
			console.log(err);
			response.send("ERROR! Can't make the directory! \n");    // echo the result back
		}
	});
}	
var PastesLinks = new Mongo.Collection("pastesLinks"); //connection to Group Collection //var=> not sharable

String.prototype.trunc = String.prototype.trunc ||
	function(n){
		return this.length>n ? this.substr(0,n) : this;
	};

Meteor.methods({ //called by Clients
	addPaste: function (blob, title, lang, author) {
		var pasteInfo = [];
		var pasteName = Array(pastesNameLenght).join().split(',').map(function() { return s.charAt(Math.floor(Math.random() * s.length)); }).join('');
		var filePath = path.join(pastesPath, pasteName + ".txt");
		var buffer = new Buffer( blob );
		fs.writeFileSync( filePath, buffer);
		PastesLinks.insert({
			link: filePath,
			title: title,
			name: pasteName,
			createdAt: new Date(),
			owner: author,
			language: lang,
			ip: this.connection.clientAddress
		});
		pasteInfo.push(pasteName);
		return pasteInfo;
	},
	getPaste: function (pasteName) {
		try{
			var pasteInfo = {}; //EJSON to return to the client
			pasteName = pasteName.replace(/\.\./g,"").replace(/\//g,"").replace(/ /g,"").replace(/\n/g,"").replace(/\v/g,"").replace(/\f/g,""); //sanitize
			pasteName = pasteName.trunc(pastesNameLenght); //truncation
			pasteInfo.text = Assets.getText("pastes/" + pasteName + ".txt"); //Assets read from /private/
			pasteInfoFromDb = PastesLinks.findOne({name: ""+pasteName})
			pasteInfo.title = pasteInfoFromDb.title;
			pasteInfo.lang = pasteInfoFromDb.language;
			return pasteInfo;
		}catch(e){
			console.log(e);
			return 1;
		}
	},
	getUserPastes: function (userName) {
		try{
			var userPastes = {};
			userPastes.userPastes = PastesLinks.find({owner: userName}).fetch();
			return userPastes;
		}catch(e){
			console.log(e);
			return 1;
		}
	}
});<commit_msg>semicolon<commit_after>var fs = Npm.require('fs');
var path = Npm.require( 'path' );
var pathAdjustment = Assets.getText("path.json");
console.log(pathAdjustment);
var __ROOT_APP_PATH__ = fs.realpathSync(pathAdjustment); //current path
var pastesPath = path.join(__ROOT_APP_PATH__, "/private/pastes/");

console.log(pastesPath);
var s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789£$&^"; //allowed char for paste's name
var pastesNameLenght = 7;



if(!fs.existsSync(pastesPath)){
	fs.mkdirSync(pastesPath, 0766, function(err){
		if(err){ 
			console.log(err);
			response.send("ERROR! Can't make the directory! \n");    // echo the result back
		}
	});
}	
var PastesLinks = new Mongo.Collection("pastesLinks"); //connection to Group Collection //var=> not sharable

String.prototype.trunc = String.prototype.trunc ||
	function(n){
		return this.length>n ? this.substr(0,n) : this;
	};

Meteor.methods({ //called by Clients
	addPaste: function (blob, title, lang, author) {
		var pasteInfo = [];
		var pasteName = Array(pastesNameLenght).join().split(',').map(function() { return s.charAt(Math.floor(Math.random() * s.length)); }).join('');
		var filePath = path.join(pastesPath, pasteName + ".txt");
		var buffer = new Buffer( blob );
		fs.writeFileSync( filePath, buffer);
		PastesLinks.insert({
			link: filePath,
			title: title,
			name: pasteName,
			createdAt: new Date(),
			owner: author,
			language: lang,
			ip: this.connection.clientAddress
		});
		pasteInfo.push(pasteName);
		return pasteInfo;
	},
	getPaste: function (pasteName) {
		try{
			var pasteInfo = {}; //EJSON to return to the client
			pasteName = pasteName.replace(/\.\./g,"").replace(/\//g,"").replace(/ /g,"").replace(/\n/g,"").replace(/\v/g,"").replace(/\f/g,""); //sanitize
			pasteName = pasteName.trunc(pastesNameLenght); //truncation
			pasteInfo.text = Assets.getText("pastes/" + pasteName + ".txt"); //Assets read from /private/
			pasteInfoFromDb = PastesLinks.findOne({name: ""+pasteName});
			pasteInfo.title = pasteInfoFromDb.title;
			pasteInfo.lang = pasteInfoFromDb.language;
			return pasteInfo;
		}catch(e){
			console.log(e);
			return 1;
		}
	},
	getUserPastes: function (userName) {
		try{
			var userPastes = {};
			userPastes.userPastes = PastesLinks.find({owner: userName}).fetch();
			return userPastes;
		}catch(e){
			console.log(e);
			return 1;
		}
	}
});
{'fraction_non_alphanumeric': 0.16901112744068864, 'fraction_numerical': 0.007558261599832038, 'mean_word_length': 4.252480705622933, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2799425', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1652, 'n_words': 344}