Diff
Not logged in

Differences From Artifact [3e85c6490e]:

To Artifact [f4f2c19a1f]:


4
5
6
7
8
9
10
11
12


13
14
15
16
17
18
19
..
29
30
31
32
33
34
35
36

37


38
39
40
41
42
43
44
..
48
49
50
51
52
53
54
55

56

57
58
59
60
61
62
const base = require('./_base');
const MDataInfoHandle = require('./_mutable').types.MDataInfoHandle;
const t = base.types;
const h = base.helpers;

const File = Struct({
  size: t.u64,
  created: t.Time, // TODO fix it for TM
  modified: t.Time, // TODO fix it for TM


  user_metadata_ptr: t.u8Pointer,
  user_metadata_len: t.usize,
  user_metadata_cap: t.usize,
  data_map_name: t.XOR_NAME
});

const FilePtr = ref.refType(File);
................................................................................
    file_update: [t.Void, [t.AppPtr, MDataInfoHandle, 'string', FilePtr, t.u64, 'pointer', 'pointer']]
  },
  api: {
    file_fetch: h.Promisified(null, [FilePtr, t.u64], (res) => {
      const file = res[0].deref();
      const data_map_name = file.data_map_name;
      const size = file.size;
      const created = file.created;

      const modified = file.modified;


      let metadata = file.user_metadata_len > 0
        ? ref.reinterpret(file.user_metadata_ptr, file.user_metadata_len) : null;

      if (metadata) {
        // we try to understand it as JSON
        try {
          metadata = JSON.parse(metadata);
................................................................................
            console.warn(`Parsing user metadata '${metadata}' of '${data_map_name}' failed: ${e}`)
          }
        }
      }
      return {metadata,
              data_map_name,
              size,
              created,

              modified,

              version: res[1]}
    }),
    file_insert: h.Promisified(null, []),
    file_update: h.Promisified(null, [])
  }
}







|
|
>
>







 







|
>
|
>
>







 







|
>
|
>






4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const base = require('./_base');
const MDataInfoHandle = require('./_mutable').types.MDataInfoHandle;
const t = base.types;
const h = base.helpers;

const File = Struct({
  size: t.u64,
  created_sec: t.i64,
  created_nsec: t.u32,
  modified_sec: t.i64,
  modified_nsec: t.u32,
  user_metadata_ptr: t.u8Pointer,
  user_metadata_len: t.usize,
  user_metadata_cap: t.usize,
  data_map_name: t.XOR_NAME
});

const FilePtr = ref.refType(File);
................................................................................
    file_update: [t.Void, [t.AppPtr, MDataInfoHandle, 'string', FilePtr, t.u64, 'pointer', 'pointer']]
  },
  api: {
    file_fetch: h.Promisified(null, [FilePtr, t.u64], (res) => {
      const file = res[0].deref();
      const data_map_name = file.data_map_name;
      const size = file.size;
      const created_sec = file.created_sec;
      const created_nsec = file.created_nsec;
      const modified_sec = file.modified_sec;
      const modified_nsec = file.modified_nsec;

      let metadata = file.user_metadata_len > 0
        ? ref.reinterpret(file.user_metadata_ptr, file.user_metadata_len) : null;

      if (metadata) {
        // we try to understand it as JSON
        try {
          metadata = JSON.parse(metadata);
................................................................................
            console.warn(`Parsing user metadata '${metadata}' of '${data_map_name}' failed: ${e}`)
          }
        }
      }
      return {metadata,
              data_map_name,
              size,
              created_sec,
              created_nsec,
              modified_sec,
              modified_nsec,
              version: res[1]}
    }),
    file_insert: h.Promisified(null, []),
    file_update: h.Promisified(null, [])
  }
}