Skip to content

Commit e3fa052

Browse files
committed
roll back google changes
1 parent c6dd680 commit e3fa052

3 files changed

Lines changed: 34 additions & 14 deletions

File tree

release/remotestorage.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/remotestorage.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/googledrive.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,36 @@ class FileIdCache {
108108
}
109109
}
110110

111+
/**
112+
* Overwrite BaseClient's getItemURL with our own implementation
113+
*
114+
* TODO: Still needs to be implemented. At the moment it just throws
115+
* and error saying that it's not implemented yet.
116+
*
117+
* @param {object} rs - RemoteStorage instance
118+
*
119+
* @private
120+
*/
121+
function hookGetItemURL (rs): void {
122+
if (rs._origBaseClientGetItemURL) { return; }
123+
rs._origBaseClientGetItemURL = BaseClient.prototype.getItemURL;
124+
BaseClient.prototype.getItemURL = function (/* path */): never {
125+
throw new Error('getItemURL is not implemented for Google Drive yet');
126+
};
127+
}
128+
129+
/**
130+
* Restore BaseClient's getItemURL original implementation
131+
*
132+
* @param {object} rs - RemoteStorage instance
133+
*
134+
* @private
135+
*/
136+
function unHookGetItemURL (rs): void {
137+
if (!rs._origBaseClientGetItemURL) { return; }
138+
BaseClient.prototype.getItemURL = rs._origBaseClientGetItemURL;
139+
delete rs._origBaseClientGetItemURL;
140+
}
111141

112142
/**
113143
* @class GoogleDrive
@@ -702,18 +732,6 @@ class GoogleDrive extends RemoteBase implements Remote {
702732
*
703733
* @protected
704734
*/
705-
/**
706-
* Google Drive does not support unauthenticated public file access, so
707-
* this always resolves to ``undefined``. See GitHub issue #1051 for the
708-
* full discussion.
709-
*
710-
* Implements {@link Remote.getItemURL}.
711-
*/
712-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
713-
async getItemURL (_path: string): Promise<string | undefined> {
714-
return undefined;
715-
}
716-
717735
static _rs_init (remoteStorage): void {
718736
const config = remoteStorage.apiKeys.googledrive;
719737
if (config) {
@@ -722,6 +740,7 @@ class GoogleDrive extends RemoteBase implements Remote {
722740
remoteStorage._origRemote = remoteStorage.remote;
723741
remoteStorage.remote = remoteStorage.googledrive;
724742

743+
hookGetItemURL(remoteStorage);
725744
}
726745
}
727746
}
@@ -750,6 +769,7 @@ class GoogleDrive extends RemoteBase implements Remote {
750769
remoteStorage.remote = remoteStorage._origRemote;
751770
delete remoteStorage._origRemote;
752771
}
772+
unHookGetItemURL(remoteStorage);
753773
}
754774
}
755775

0 commit comments

Comments
 (0)