exodus-framework 2.0.9998 → 2.0.9999
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileLibrary.d.ts","sourceRoot":"","sources":["../../../src/services/file/FileLibrary.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,cAAM,kBAAmB,SAAQ,OAAO;IACtC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;IAEZ,aAAa;IAQb,OAAO;YAMN,WAAW;YA2BX,iBAAiB;IAwBxB,WAAW,CAAC,GAAG,EAAE,MAAM;IAOjB,UAAU,CAAC,GAAG,EAAE,MAAM;IAO5B,aAAa,CAAC,GAAG,EAAE,MAAM;IAOnB,UAAU,CAAC,GAAG,EAAE,MAAM;IAWtB,WAAW,CAAC,GAAG,EAAE,MAAM;
|
1
|
+
{"version":3,"file":"FileLibrary.d.ts","sourceRoot":"","sources":["../../../src/services/file/FileLibrary.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,cAAM,kBAAmB,SAAQ,OAAO;IACtC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;IAEZ,aAAa;IAQb,OAAO;YAMN,WAAW;YA2BX,iBAAiB;IAwBxB,WAAW,CAAC,GAAG,EAAE,MAAM;IAOjB,UAAU,CAAC,GAAG,EAAE,MAAM;IAO5B,aAAa,CAAC,GAAG,EAAE,MAAM;IAOnB,UAAU,CAAC,GAAG,EAAE,MAAM;IAWtB,WAAW,CAAC,GAAG,EAAE,MAAM;IAWvB,mBAAmB,CAAC,QAAQ,EAAE,MAAM;IAmCpC,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IA2B7E,cAAc,CAAC,QAAQ,EAAE,MAAM;IAW/B,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAMxC,QAAQ,CAAC,GAAG,EAAE,MAAM;CAG5B;AAED,eAAe,kBAAkB,CAAC"}
|
@@ -56,7 +56,7 @@ class FileLibraryService extends _service.default {
|
|
56
56
|
const itemPath = _path.default.join(target, item);
|
57
57
|
const stat = await _fsExtra.default.stat(itemPath);
|
58
58
|
if (stat.isDirectory()) {
|
59
|
-
this.migratePublicPath(itemPath);
|
59
|
+
await this.migratePublicPath(itemPath);
|
60
60
|
continue;
|
61
61
|
}
|
62
62
|
const md5 = await this.getMD5FromFile(itemPath);
|
@@ -97,16 +97,13 @@ class FileLibraryService extends _service.default {
|
|
97
97
|
|
98
98
|
/**
|
99
99
|
* Save a file to the library and register it in the cache
|
100
|
-
*
|
101
|
-
* @param {string} filePath
|
102
|
-
* @return {string} MD5 hash of the saved file
|
103
|
-
* @memberof FileLibraryService
|
100
|
+
* @return MD5 hash of the saved file
|
104
101
|
*/
|
105
102
|
async saveAndRegisterFile(filePath) {
|
106
103
|
const md5 = await this.getMD5FromFile(filePath);
|
107
104
|
if (!md5) throw new Error('Falha ao gerar o md5 do arquivo');
|
108
105
|
if (this.isCached(md5)) return;
|
109
|
-
const ext = this.mime.
|
106
|
+
const ext = this.mime.getFileExtension(filePath);
|
110
107
|
const newFilePath = _path.default.join(this.path, `${md5}.${ext}`);
|
111
108
|
const metaFilePath = _path.default.join(this.path, `${md5}.meta`);
|
112
109
|
await _fsExtra.default.move(filePath, newFilePath, {
|
@@ -130,12 +127,7 @@ class FileLibraryService extends _service.default {
|
|
130
127
|
|
131
128
|
/**
|
132
129
|
* Save a file buffer to the library and register it in the cache
|
133
|
-
*
|
134
|
-
* @param {Buffer} buffer
|
135
|
-
* @param {string} originalName
|
136
|
-
* @param {string} ext
|
137
|
-
* @return {string} MD5 hash of the saved file
|
138
|
-
* @memberof FileLibraryService
|
130
|
+
* @return MD5 hash of the saved file
|
139
131
|
*/
|
140
132
|
async saveAndRegisterBuffer(buffer, originalName, ext) {
|
141
133
|
const md5 = this.getMD5FromBuffer(buffer);
|
@@ -8,6 +8,7 @@ declare class MimeType {
|
|
8
8
|
constructor(...args: TypeMap[]);
|
9
9
|
define(typeMap: TypeMap, force?: boolean): this;
|
10
10
|
getType(path: string): string;
|
11
|
+
getFileExtension(path: string): string;
|
11
12
|
getExtension(type: string): string;
|
12
13
|
getAllExtensions(type: string): Set<string>;
|
13
14
|
_freeze(): this;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Mimetyp.d.ts","sourceRoot":"","sources":["../../../../src/services/file/classes/Mimetyp.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3C,cAAM,QAAQ;IACZ,eAAe,sBAA6B;IAC5C,eAAe,sBAA6B;IAC5C,gBAAgB,2BAAkC;gBAEtC,GAAG,IAAI,EAAE,OAAO,EAAE;IAMvB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,UAAQ;IA8CtC,OAAO,CAAC,IAAI,EAAE,MAAM;IAqBpB,YAAY,CAAC,IAAI,EAAE,MAAM;IAYzB,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAUpC,OAAO;IAgBP,aAAa;;;;CAMd;AAED,eAAe,QAAQ,CAAC"}
|
1
|
+
{"version":3,"file":"Mimetyp.d.ts","sourceRoot":"","sources":["../../../../src/services/file/classes/Mimetyp.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3C,cAAM,QAAQ;IACZ,eAAe,sBAA6B;IAC5C,eAAe,sBAA6B;IAC5C,gBAAgB,2BAAkC;gBAEtC,GAAG,IAAI,EAAE,OAAO,EAAE;IAMvB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,UAAQ;IA8CtC,OAAO,CAAC,IAAI,EAAE,MAAM;IAqBpB,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAe7B,YAAY,CAAC,IAAI,EAAE,MAAM;IAYzB,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAUpC,OAAO;IAgBP,aAAa;;;;CAMd;AAED,eAAe,QAAQ,CAAC"}
|
@@ -68,6 +68,20 @@ class MimeType {
|
|
68
68
|
return this.extensionToType.get(ext) ?? null;
|
69
69
|
}
|
70
70
|
|
71
|
+
/**
|
72
|
+
* Get extension associated with a filepath
|
73
|
+
*/
|
74
|
+
getFileExtension(path) {
|
75
|
+
if (typeof path !== 'string') return null;
|
76
|
+
|
77
|
+
// Remove chars preceeding `/` or `\`
|
78
|
+
const last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
79
|
+
|
80
|
+
// Remove chars preceeding '.'
|
81
|
+
const ext = last.replace(/^.*\./, '').toLowerCase();
|
82
|
+
return ext;
|
83
|
+
}
|
84
|
+
|
71
85
|
/**
|
72
86
|
* Get default file extension associated with a mime type
|
73
87
|
*/
|