• Blog posts


    by Luke Davenport


    Question: 'How can I isolate local workspace files that have not been checked into (therefore don't exist in) the Vault?'


    At Cadline we occasionally get asked for Vault workspace housekeeping tips, such as an answer to the above question. We are looking to avoid having locally saved work that the Vault database isn't aware of, and is therefore potentially not backed up and vulnerable to accidental deletion.


    There are of course several ways of dealing with this, and it all depends on your preferred (or company dictated) method of working with Vault. You can:


    1)       Tick the box to 'Close Files and Delete Working Copies' upon checking in files to Vault – this'll keep your workspace nice and clean – only WIP files or unvaulted files will be present.

    2)      Use the 'Workspace Sync' tool in Vault – which will allow you to compare your local workspace against the Vault database and refresh your local workspace accordingly.

    However, sometimes it's nice to have a little utility up your sleeve, so here's a quick iLogic rule that may help.


    What does it do?


    It finds all of the read-only files in your Vault Workspace and then gives you the option of deleting them all.




    Well as the rule will delete all the files that Vault knows about, you can be sure that any files that remain only exist in your local workspace (Vault doesn't know about them), and therefore they need to be loaded into Vault (checked in) pronto to avoid losing them, and so that your colleagues can see your sterling work.


    How should I use it?


    1)      First do a search for all files checked out to you in Vault. – See this great blog by Chris Turner for details -http://bit.ly/1muLmKK

    2)      Check in all of the files that are checked out to you.

    3)      Now you can be reasonably confident (assuming no tampering with read-only properties of files in your Vault workspace has taken place) that in your Vault Workspace - any files that Vault knows about will be read-only (locked) and files that Vault has no idea about will be read-write (not locked).

    4)      Take a backup of your local Vault Workspace folder – this is important!

    5)      Then run the iLogic rule.

    6)      Now any files left in your Vault Workspace are files that probably need to be loaded into Vault.

    Please use the code with extreme caution! Cadline cannot accept any responsibility for lost files as a result of using this code.


    Also note: If there's a chance that anyone has manually added read-only properties to files inside your Vault Workspace don't even consider using this tool, as you might delete files that aren't in the Vault at all. Beware!


    And here's the code. As always, be careful when copying and pasting into an iLogic rule, that you don't add additional blank lines when pasting - that will confuse the code.


    Note: You will need to adjust the line below (in the main code) to match your actual Vault workspace location.


    Dim SearchLocation As String = "C:\VAULT WORKSPACE\Designs"

    Note also: The code will search all subfolders of the folder you point it to. If you have Vaulted design data and templates it's probably best not to include these folders (as you'll have to download them from the Vault again if they are deleted!)


    Enjoy and play safe…


    'Start of iLogic code
    'Note to self -
    'Remember to subscribe To Luke Davenport's blog and follow him on Twitter @LukeCadline
    Imports System
    Imports System.IO
    Imports System.Text
    Sub Main
    oDoc = ThisDoc.Document
    ' Note - enter your Vault Workspace local folder location here.....
    Dim SearchLocation As String = "C:\VAULT WORKSPACE\Designs"
    Dim filelist As New List(Of String)
    Call GetAllReadOnlyFiles(SearchLocation, filelist)
    If filelist.count > 0 Then
        i = MessageBox.Show(filelist.count & " Read-Only file(s) found - Delete Them?" & vbLf & vbLf & _
        "Note: Please use this code with extreme caution - Cadline cannot be held responsible for files deleted in error" & vbLf & vbLf & _
        "Note: It cannot be guaranteed that read-only files are actually checked into Vault and exist in the Vault database - only proceed if you are sure...", _
        "Cadline iLogic",MessageBoxButtons.YesNo,MessageBoxIcon.Question) 
        If i = vbNo Then
        End If
        MessageBox.Show("No Read-Only files were found in selected folder - Exiting Rule...", "Cadline iLogic")
    End If
    For Each strfile As String In filelist
        System.IO.File.SetAttributes(strfile, IO.FileAttributes.Normal)
    End Sub
     Sub GetAllReadOnlyFiles(ByVal SearchLocation As String, ByRef filelist As List(Of String))
            For Each file As String In Directory.GetFiles(SearchLocation)
                Dim attributes = IO.File.GetAttributes(file)
                   If ((attributes And FileAttributes.ReadOnly) = FileAttributes.ReadOnly) Then    
                End If
            For Each dir As String In Directory.GetDirectories(SearchLocation)
                If Not dir.Contains("_V") Then
                        GetAllReadOnlyFiles(dir, filelist)
                    End Try
                End If
     End Sub
     ' End of iLogic code...............