Skip to content

Commit 4321706

Browse files
committed
fix: #538 getURL should provide a data object for large size medias when in local/inmemory partition
Adds maxDataURISourceBytes = 48000 as regular data URI ceiling Adds PartitionConnection.isRemote() Removes the maxDataURISourceBytes check for !isRemote() connections
1 parent cc45349 commit 4321706

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/prophet/Scribe/_contentOps.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,21 @@ export function _decodeBvobContent (scribe: Scribe, bvobInfo: BvobInfo,
174174
], onError);
175175
}
176176

177+
const maxDataURISourceBytes = 48000;
178+
177179
export function _getMediaURL (connection: ScribePartitionConnection, mediaInfo: MediaInfo,
178180
mediaEntry: MediaEntry, onError: Function): any {
179181
// Only use cached in-memory nativeContent if its id matches the requested id.
180182
const bvobId = (mediaInfo && mediaInfo.bvobId) || mediaEntry.mediaInfo.bvobId;
181183
const bvobInfo = connection._prophet._bvobLookup[bvobId || ""];
182184
// Media's with sourceURL or too large/missing bvobs will be handled by Oracle
183-
if (!bvobInfo || !(bvobInfo.byteLength <= 10000)) return undefined;
185+
if (!bvobInfo) return undefined;
186+
if (!(bvobInfo.byteLength <= maxDataURISourceBytes)) {
187+
if (connection.isRemote()) return undefined;
188+
connection.warnEvent(`getMediaURL requested on a local Media "${mediaInfo.name
189+
}" of ${bvobInfo.byteLength} bytes, larger than recommended ${maxDataURISourceBytes
190+
} bytes for data URI's.`,
191+
"However as no Service Worker implementation is found returning as large data URI anyway.");
184192
}
185193
// TODO(iridian): With systems that support Service Workers we will eventually return URL's which
186194
// the service workers recognize and can redirect to 'smooth' IndexedDB accesses, see

packages/prophet/api/PartitionConnection.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ export default class PartitionConnection extends LogEventGenerator {
4444
partitionURI (): ValaaURI { return this._partitionURI; }
4545
partitionRawId (): string { return getPartitionRawIdFrom(this._partitionURI); }
4646

47+
isRemote () { return !this.isLocal() && !this.isMemory(); }
4748
isLocal () { return this._partitionURI.protocol === "valaa-local:"; }
48-
isTransient () {
49+
isMemory () {
4950
return (this._partitionURI.protocol === "valaa-transient:")
5051
|| (this._partitionURI.protocol === "valaa-memory:");
5152
}
53+
isTransient () { return this.isMemory(); }
5254

5355
isConnected () {
5456
if (this._upstreamConnection) return this._upstreamConnection.isConnected();

0 commit comments

Comments
 (0)