Commit 9be85871 authored by Avi's avatar Avi

Updated and removed extra params and accessing results in gio-head from load_contents_promise

parent fbccd009
......@@ -2,11 +2,11 @@ const {GLib, Gio} = imports.gi;
let loop = GLib.MainLoop.new(null, false);
const load_contents_promise = (file, cancellable = null, content)=>{
const load_contents_promise = (file)=>{
return new Promise((resolve, reject)=>{
file.load_contents_async(null, function(f, res) {
try {
let result = f.load_contents_finish(res)[1];
let result = f.load_contents_finish(res);
resolve(result);
} catch (error) {
reject(error);
......@@ -21,7 +21,12 @@ const head = async(filename)=>{
let content_formatted;
try {
raw_content = await load_contents_promise(file);
content_formatted = raw_content.toString();
/* Prints 'true' as load was successful */
// content_formatted = raw_content[0].toString();
/* Get only the results with raw_content[1] instead of printing all of the values */
content_formatted = raw_content[1].toString();
/* Prints '1527301825:698952' for the location of the contents */
// content_formatted = raw_content[2].toString();
print(content_formatted.split('\n', 10).join('\n'));
} catch (error) {
logError(error);
......
......@@ -14,11 +14,11 @@
error GError a GError, or `NULL`
);
*/
const load_contents_promise = (file, cancellable = null, content)=>{
const load_contents_promise = (file)=>{
return new Promise((resolve, reject)=>{
file.load_contents_async(null, function(f, res) {
try {
let result = f.load_contents_finish(res)[1];
let result = f.load_contents_finish(res);
resolve(result);
} catch (error) {
reject(error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment