Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Commit

Permalink
Fix FFI usage of dns_get_file_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
vinipsmaker committed Nov 17, 2016
1 parent 98d5f1b commit 9fcf0ea
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/ffi/api/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,15 @@ class DNS extends FfiApi {

getFileMetadata(app, longName, serviceName, path) {
return new Promise((resolve, reject) => {
const fileMetadataRefRef = ref.alloc(PointerToFileMetadataPointer);
const fileMetadataHandle = ref.alloc(FileMetadataHandle);
const onResult = (err, res) => {
if (err || res !== 0) {
log.error(`FFI :: DNS :: Get file metadata :: ${err || res}`);
return reject(err || res);
}
try {
const fileMetadataHandle = fileMetadataRefRef.deref();
const fileMetadataRef = ref.alloc(FileMetadataHandle, fileMetadataHandle).deref();
const metadata = derefFileMetadataStruct(fileMetadataRef.deref());
this.safeCore.file_metadata_drop.async(fileMetadataHandle, () => {});
const metadata = derefFileMetadataStruct(new FileMetadata(fileMetadataHandle.deref()));
this.safeCore.file_metadata_drop.async(fileMetadataHandle.deref(), () => {});
resolve(metadata);
} catch (e) {
log.warn(`FFI :: DNS :: Get file metadata :: Caught exception -
Expand All @@ -233,7 +231,7 @@ class DNS extends FfiApi {
longNameBuffer, longNameBuffer.length,
serviceNameBuffer, serviceNameBuffer.length,
pathBuffer, pathBuffer.length,
fileMetadataRefRef, onResult);
fileMetadataHandle, onResult);
});
}

Expand Down

0 comments on commit 9fcf0ea

Please sign in to comment.