ktheod / OneDriveBully

Bully your OneDrive to sync Symbolic Link Folders
GNU General Public License v3.0
304 stars 20 forks source link

[Suggest/issue] Manually adding already created Symbolic links or look for them in subfolders of onedrive #13

Closed WardenHub closed 3 years ago

WardenHub commented 4 years ago

Hey.. first off I love the bully program.. my own implementation spammed the users the folders are shared with with tempfiles that were added/removed.

However I have already created symbolink links (about 9) in a subfolder of the main onedrive folder and the program isn't reckognising them.

Any chance this can be solved

ktheod commented 3 years ago

Hi WardernHub, sorry for the very late reply but just checked the page again.

Your symlinks might not be visible to Bully because there are different types of symlinks that you can create with cmd. If it helps, you can check file MyFunctions.cs for function getOneDriveForSymLinks() which populates the Settings Table.

ktheod commented 3 years ago
    public DataTable getOneDriveForSymLinks()
    {
        DataTable SymLinksTable = new DataTable();
        SymLinksTable.Columns.Add("Folder Path", typeof(string));
        SymLinksTable.Columns.Add("OneDrive Path", typeof(string));
        SymLinksTable.Columns.Add("Folder Name", typeof(string));

        Properties.Settings.Default.Reload();
        string[] subDirs = Directory.GetDirectories(Properties.Settings.Default.OneDriveRootFolder);

        SymbolicLink sl = new SymbolicLink();

        foreach (string subDir in subDirs)
        {
            if (IsSymbolic(@subDir))
            {
                string targetF = sl.GetSymLinkTarget(@subDir);
                Console.WriteLine(subDir.ToString() + " - " + IsSymbolic(@subDir)
                                  + " ==> " + @targetF);
                SymLinksTable.Rows.Add(@targetF, @subDir, getFolderName(subDir));
            }
        }
        return SymLinksTable;
    }

    private bool IsSymbolic(string path)
    {
        FileInfo pathInfo = new FileInfo(path);
        return pathInfo.Attributes.HasFlag(FileAttributes.ReparsePoint);
    }
micahmo commented 3 years ago

Hi @ktheod,

First of all, I love the app. It is very helpful and solves a very real problem.

Second, I have the same issue as @WardenHub. I have already created several directory links (technically junctions, aka mount points) in OneDrive, and I think it would be cool if OneDrive Bully detected them automatically (even though the syncing feature works perfectly even without the links displayed in the UI).

I opened PR #14 with the changes that I think are necessary to solve OP's and my issue. Please see my comments there for an explanation of the changes.