-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option take last commit time into account for backup #73
Comments
I see your point, but honestly that's not really what I understand under an auto backup. |
The plugin's auto-backup internal timer is reset once you manually commit from within Obsidian. Tracking commits made from outside of Obsidian would be overkill. |
@denolehov Are you sure? Did I remove that with my changes? I can only find the update of |
Personally, I am fine with either having a backup timer reset on manual commit from within Obsidian UI or not having it reset at all and have it free-running. But in any case, having a reset timer rely on git history (i.e. periodically fetching git log and seeing what was the latest timestamp) is definitely an overkill. But maybe it's just me, and if more people request this change, we could perhaps implement a "Backup Mode" where people would be able to choose whether they want to have the timer free-running or be based on the latest commit, or be reset on manual commits from Obsidian. |
I imagined the plugin wouldn't need to check the git log periodically, only on startups and before scheduled backups, like with |
For anyone still interested, I found a workaround with git hooks. It works well for me on Windows.
This makes the shell print the current date in JavaScript's Date.parse() format used by the plugin. |
This seems to be broken again @Vinzent03, would you reopen the issue? Auto backup only considers when the last auto backup was, not even manual backups from the app. The |
I switched from an extra file to |
I seem to remember this was fixed, but maybe not. Either way, it doesn't work now. I hope you can reproduce it. Is the |
I think that's right To conclude, this feature isn't currently planned, because that's not what I understand under planned automatic backups. They should run independent of manual backups. |
"I think that's right", as in there's no way for outside git operations to influence the plugin? I would have liked to use this functionality as something that makes a backup when neither automatic nor manual backups were made for a while. |
@Vinzent03 could you confirm this? |
@NomarCub I don't really know what exactly you want to influence, but you would need another plugin to interact with this plugin to achieve this feature request. I will reopen this issue, but the backup system is already a bit complicated and I don't know if I would merge a pull request, because I don't want to overcomplicate things. |
My foremost goal is the functionality, so maybe I should rephrase it. I'd like some mechanism, whereby a backup is made automatically when the last backup is over a specified age. Maybe the last backup was an automatic one, maybe a manual one, (or even a commit made outside Obsidian, but if that's hard to deal with it's fine if that is not addressed in this PR). The current auto backup feature doesn't do this, it triggers in relation to the last auto backup, not any backup (or commit), even if say, a manual backup was made recently. Ideally for me, you or someone familiar with the plugin would implement this.
If auto backup should only do what you described, then let's call this new mechanism scheduled fallback or something, to make it clear to people that it's something different. "The backup system is already a bit complicated" sounds to me like the code is hard to extend and should be refactored to make further changes easier. But if that time investment is not justified, and you're against this being included in the plugin I understand. |
With too complicated, I meant there are already many settings for auto backup. By adding another option, it may be too complicated for the user to understand everything. Giving it a different name, may be helpful. You can only access the localStorage from an Obsidian plugin or a script running directly in Obsidian (I think there are some plugins to run js). When writing your own plugin, I suggest you to use this plugin's api to run a backup. |
I am trying my hand at this, and I think I am done on desktop, but I don't know how to do it on mobile. Right now I use @Vinzent03 Could you either please:
|
Since you only want the timestamp, this should do the trick. Use the example at the bottom and replace |
What object do I call and readCommit on? gitManager doesn't have it on mobile. |
May you just create the pull requests and I do the isogit part? |
I thought this functionality is not intended, so no pull request would be accepted. I load my script using User Plugins. This is what I have so far: module.exports = {};
module.exports.onload = function (plugin) {
if (app.isMobile) return;
(async () => {
const gitPlugin = app.plugins.plugins['obsidian-git'];
const log = await gitPlugin.gitManager.log(); // SimpleGit.log()
const date = log.first().date;
// const lastAuto = await gitPlugin.loadLastAuto();
gitPlugin.saveLastAuto(new Date(date), 'backup');
})().catch((err) => console.error(err));
}; |
I've done it now! The new setting |
I'd like the plugin to optionally check the last commit time and update the last auto-backup time to that.
For example let's say the last auto-backup was 30 minutes ago, the interval is an hour and I make a manual commit now. With this option auto-backup won't trigger 30 minutes from now, but an hour from now, an hour from the last commit.
The text was updated successfully, but these errors were encountered: