| 1811 | } |
| 1812 | |
| 1813 | func findSqliteFiles(root string) ([]sqliteCandidate, error) { |
| 1814 | var files []sqliteCandidate |
| 1815 | skipDirs := map[string]struct{}{ |
| 1816 | ".git": {}, |
| 1817 | ".idea": {}, |
| 1818 | ".vscode": {}, |
| 1819 | "node_modules": {}, |
| 1820 | "vendor": {}, |
| 1821 | } |
| 1822 | |
| 1823 | err := filepath.WalkDir(root, func(path string, d fs.DirEntry, walkErr error) error { |
| 1824 | if walkErr != nil { |
| 1825 | if errors.Is(walkErr, fs.ErrPermission) { |
| 1826 | return nil |
| 1827 | } |
| 1828 | return walkErr |
| 1829 | } |
| 1830 | |
| 1831 | if d.IsDir() { |
| 1832 | if path == root { |
| 1833 | return nil |
| 1834 | } |
| 1835 | if _, skip := skipDirs[d.Name()]; skip { |
| 1836 | return filepath.SkipDir |
| 1837 | } |
| 1838 | return nil |
| 1839 | } |
| 1840 | |
| 1841 | if !strings.EqualFold(filepath.Ext(d.Name()), ".sqlite") { |
| 1842 | return nil |
| 1843 | } |
| 1844 | |
| 1845 | rel, err := filepath.Rel(root, path) |
| 1846 | if err != nil { |
| 1847 | rel = path |
| 1848 | } |
| 1849 | |
| 1850 | files = append(files, sqliteCandidate{ |
| 1851 | Absolute: path, |
| 1852 | Relative: rel, |
| 1853 | }) |
| 1854 | return nil |
| 1855 | }) |
| 1856 | if err != nil { |
| 1857 | return nil, err |
| 1858 | } |
| 1859 | |
| 1860 | sort.Slice(files, func(i, j int) bool { |
| 1861 | return files[i].Relative < files[j].Relative |
| 1862 | }) |
| 1863 | |
| 1864 | return files, nil |
| 1865 | } |
| 1866 | |
| 1867 | func openInTablePlus(ctx *snap.Context, databasePath string) error { |
| 1868 | tablePlusApp := "/Applications/TablePlus.app" |