Skip to content
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

Object Corruption #7

Open
DovieW opened this issue Dec 19, 2023 · 8 comments
Open

Object Corruption #7

DovieW opened this issue Dec 19, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@DovieW
Copy link
Owner

DovieW commented Dec 19, 2023

Screenshot_20231218-234554.png

@DovieW DovieW added the bug Something isn't working label Dec 19, 2023
@DovieW
Copy link
Owner Author

DovieW commented Dec 24, 2023

Screenshot_20231223-192131.png

@DovieW
Copy link
Owner Author

DovieW commented Dec 24, 2023

When i get such issues, just going into the directory in Termux and running git sync -ns works

@DovieW
Copy link
Owner Author

DovieW commented Jan 21, 2024

Doesn't seem to actually be a network issue. if i run the Sync (all) Vaults script, it just keeps happening.

@DovieW
Copy link
Owner Author

DovieW commented Apr 10, 2024

the network error is from the git-sync script so that can be ignored.

I was able to fix the object file is empty with git fsck --full

If you need the changes from the remote, a safe bet is git fetch && git reset @{u}

@DovieW
Copy link
Owner Author

DovieW commented Apr 10, 2024

maybe the fix would be to auto git fsck --full if a sync fails. and that can be toggled with an env var and it defaults to true

@DovieW
Copy link
Owner Author

DovieW commented Oct 16, 2024

termux/termux-app#3777
consider solution in last comment

@DovieW DovieW changed the title Sometimes sync fails Object Corruption Oct 28, 2024
@DovieW DovieW pinned this issue Oct 28, 2024
@DovieW
Copy link
Owner Author

DovieW commented Oct 28, 2024

@DovieW
Copy link
Owner Author

DovieW commented Oct 29, 2024

made this script to move all my vaults to termux storage and do the worktrees thing. so far seems to be working (I think its signifcantly faster too). will check back in a couple weeks to see if it solved the issue.

the script (thanks chatgpt):

#!/bin/bash
set -euo pipefail

# Colors for echo commands
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

# Source and destination paths
SOURCE_PATH="/storage/emulated/0/repos/Obsidian"
DEST_PATH="$HOME/repos/Obsidian"

# Create the destination directory if it doesn't exist
echo -e "${YELLOW}Creating destination directory at $DEST_PATH if it doesn't exist...${NC}"
mkdir -p "$DEST_PATH"

# Move all repositories from source to destination
for repo in "$SOURCE_PATH"/*; do
  if [ -d "$repo/.git" ]; then

    if [ -f "$repo/.git" ]; then
      echo "$repo is a worktree. Skipping loop."
      continue
    fi
  
    # Get the name of the repository
    repo_name=$(basename "$repo")

    # Move the repository
    echo -e "${YELLOW}Moving repository $repo_name to $DEST_PATH...${NC}"
    mv "$repo" "$DEST_PATH/"

    # Change to the repository directory
    echo -e "${YELLOW}Changing to the repository directory $DEST_PATH/$repo_name...${NC}"
    cd "$DEST_PATH/$repo_name" || exit

    # Get the current branch name
    current_branch=$(git rev-parse --abbrev-ref HEAD)

    git switch -c empty

    # Remove all files and directories except the .git directory
    echo -e "${YELLOW}Removing all files from the working directory of $repo_name except the .git directory...${NC}"
    find . -mindepth 1 \( -not -path "./.git" -a -not -path "./.git/*" \) -exec rm -rf {} +

    # Create a worktree for the repo back to the original location, checked out to the default branch
    echo -e "${YELLOW}Creating a worktree for $repo_name back to the original location at $SOURCE_PATH/$repo_name, checked out to $current_branch...${NC}"
    mkdir -p "$SOURCE_PATH/$repo_name"
    git worktree add "$SOURCE_PATH/$repo_name" "$current_branch"
  fi
done

echo -e "${GREEN}All repositories have been moved and worktrees created.${NC}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant