Skip to content

Commit

Permalink
readme/license
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Xiong committed Nov 9, 2024
1 parent 65d6a85 commit 4be5aff
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 12 deletions.
105 changes: 101 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,104 @@
Copyright 2024 Richard Xiong
# PolyForm Strict License 1.0.0

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
<https://polyformproject.org/licenses/strict/1.0.0>

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
## Acceptance

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
In order to get any license under these terms, you must agree
to them as both strict obligations and conditions to all
your licenses.

## Copyright License

The licensor grants you a copyright license for the software
to do everything you might do with the software that would
otherwise infringe the licensor's copyright in it for any
permitted purpose, other than distributing the software or
making changes or new works based on the software.

## Patent License

The licensor grants you a patent license for the software that
covers patent claims the licensor can license, or becomes able
to license, that you would infringe by using the software.

## Noncommercial Purposes

Any noncommercial purpose is a permitted purpose.

## Personal Uses

Personal use for research, experiment, and testing for
the benefit of public knowledge, personal study, private
entertainment, hobby projects, amateur pursuits, or religious
observance, without any anticipated commercial application,
is use for a permitted purpose.

## Noncommercial Organizations

Use by any charitable organization, educational institution,
public research organization, public safety or health
organization, environmental protection organization,
or government institution is use for a permitted purpose
regardless of the source of funding or obligations resulting
from the funding.

## Fair Use

You may have "fair use" rights for the software under the
law. These terms do not limit them.

## No Other Rights

These terms do not allow you to sublicense or transfer any of
your licenses to anyone else, or prevent the licensor from
granting licenses to anyone else. These terms do not imply
any other licenses.

## Patent Defense

If you make any written claim that the software infringes or
contributes to infringement of any patent, your patent license
for the software granted under these terms ends immediately. If
your company makes such a claim, your patent license ends
immediately for work on behalf of your company.

## Violations

The first time you are notified in writing that you have
violated any of these terms, or done anything with the software
not covered by your licenses, your licenses can nonetheless
continue if you come into full compliance with these terms,
and take practical steps to correct past violations, within
32 days of receiving notice. Otherwise, all your licenses
end immediately.

## No Liability

**_As far as the law allows, the software comes as is, without
any warranty or condition, and the licensor will not be liable
to you for any damages arising out of these terms or the use
or nature of the software, under any kind of legal claim._**

## Definitions

The **licensor** is the individual or entity offering these
terms, and the **software** is the software the licensor makes
available under these terms.

**You** refers to the individual or entity agreeing to these
terms.

**Your company** is any legal entity, sole proprietorship,
or other kind of organization that you work for, plus all
organizations that have control over, are under the control of,
or are under common control with that organization. **Control**
means ownership of substantially all the assets of an entity,
or the power to direct its management and policies by vote,
contract, or otherwise. Control can be direct or indirect.

**Your licenses** are all the licenses granted to you for the
software under these terms.

**Use** means anything you do with the software requiring one
of your licenses.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,38 @@ This is an unofficial sync plugin for Obsidian, specifically for Google Drive.
- Syncing both ways (from Obsidian to Google Drive and back)
- Cross-device support
- Obsidian iOS app support

## Notes

- Do NOT manually upload files into the generated Obsidian Google Drive folder or use some other method of Google Drive sync
- Our plugin cannot see these files, and it will likely break functionality, potentially causing data loss
- Instead, use this plugin on any device you wish to sync the vault between
- Do NOT manually change files outside of the Obsidian app
- Our plugin tracks file changes through the Obsidian API, and if you change files outside of the app, the plugin will not be able to track these changes
- INITIAL activation of this plugin on a vault will DELETE ALL LOCAL FILES IN THE VAULT and REPLACE them with the files on Google Drive
- If you wish to keep those files, move them to another vault and copy them back in after syncing
- If there is no Google Drive vault, the plugin will create one and delete the contents of the local vault
- This is ONLY on the first activation or when the client is behind Google Drive's files
- We suggest only editing Obsidian notes on one device at a time to avoid conflicts and syncing before editing on another device

## Setup

Note: Instructions are also on this plugin's homepage with images at [https://obsidian.richardxiong.com](https://obsidian.richardxiong.com)

1. Visit this plugin's homepage at [https://obsidian.richardxiong.com](https://obsidian.richardxiong.com)
2. Click `Sign In` at the top right and log in with your Google account
3. Copy the refresh token that appears after logging in
4. Enable the Google Drive Sync plugin in Obsidian
5. Paste the refresh token into the plugin settings in Obsidian
6. Reload the Obsidian app

## Use

- After setup, the plugin will automatically sync your vault with Google Drive whenever Obsidian is open
- This sync is from Google Drive TO Obsidian, not the other way around (pulling cloud files)
- The plugin prioritizes changes on Google Drive over changes on the local vault, wiping local changes if the Google Drive files are newer
- To sync local changes to Google Drive, click the sync button on the ribbon or run the `Sync to Google Drive` command from the command palette
- While you do not have to sync before you close Obsidian, we suggest doing so to ensure that Google Drive is up to date
- If a device syncs to Google Drive, other devices will delete their local changes the next time they open Obsidian
- Make sure to sync with an adequate internet connection
- Closing the app or losing connection while syncing could lead to data corruption
22 changes: 14 additions & 8 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ export default class ObsidianGoogleDrive extends Plugin {

async startSync() {
this.ribbonIcon.addClass("spin");
this.syncing = true;
}

async endSync() {
this.ribbonIcon.removeClass("spin");
this.syncing = false;
}

async obsidianToGoogleDrive() {
Expand Down Expand Up @@ -268,23 +270,27 @@ export default class ObsidianGoogleDrive extends Plugin {

await refreshAccessToken(this);

const files = await this.drive.searchFiles({
include: ["id", "modifiedTime", "properties", "mimeType"],
const recentlyModified = await this.drive.searchFiles({
include: ["id"],
matches: [{ modifiedTime: { gt: this.settings.lastSyncedAt } }],
});
if (!files) {
if (!recentlyModified) {
return new Notice("An error occurred fetching Google Drive files.");
}

const latestModifiedTime = Math.max(
...files.map(({ modifiedTime }) => new Date(modifiedTime).getTime())
);

if (this.settings.lastSyncedAt > latestModifiedTime) {
if (!recentlyModified.length) {
this.settings.lastSyncedAt = Date.now();
await this.saveSettings();
return this.endSync();
}

const files = await this.drive.searchFiles({
include: ["id", "modifiedTime", "properties", "mimeType"],
});
if (!files) {
return new Notice("An error occurred fetching Google Drive files.");
}

const newFiles = files.filter(
({ modifiedTime }) =>
new Date(modifiedTime).getTime() > this.settings.lastSyncedAt
Expand Down

0 comments on commit 4be5aff

Please sign in to comment.