@@ -83,31 +83,29 @@ namespace Scratch.FolderManager {
8383 }
8484
8585 // Checks if we're dealing with a non-backup directory
86- // Hidden subfolders are not shown by default, but we need to allow hidden top-level folder
87- public bool is_valid_directory (bool allow_hidden = true ) {
88- if ((! allow_hidden && name. has_prefix (" ." )) || // If parent is hidden then inherit validity from parent
89- info. get_is_backup ()) {
90-
91- return false ;
92- }
86+ // If parent is hidden then inherit validity from parent
87+ private bool ? _is_valid_directory = null ;
88+ public bool is_valid_directory {
89+ get {
90+ if (_is_valid_directory == null ) {
91+ _is_valid_directory = info != null &&
92+ ! info. get_is_backup () &&
93+ info. get_file_type () == FileType . DIRECTORY ;
94+ }
9395
94- if (info. get_file_type () == FileType . DIRECTORY ) {
95- return true ;
96+ return _is_valid_directory;
9697 }
97-
98- return false ;
9998 }
10099
101- public bool is_temporary {
102- get {
103- return path. has_suffix (" ~" );
104- }
105- }
106-
107100 // checks if we're dealing with a textfile
101+ private bool ? _is_valid_textfile = null ;
108102 public bool is_valid_textfile {
109103 get {
110- return Utils . check_if_valid_text_file (path, info);
104+ if (_is_valid_textfile == null ) {
105+ _is_valid_textfile = ! path. has_suffix (" ~" ) && Utils . check_if_valid_text_file (path, info);
106+ }
107+
108+ return _is_valid_textfile;
111109 }
112110 }
113111
@@ -143,7 +141,7 @@ namespace Scratch.FolderManager {
143141 while ((file_info = enumerator. next_file ()) != null ) {
144142 var child = file. get_child (file_info. get_name ());
145143 var child_file = new File (child. get_path ());
146- if (child_file. is_valid_directory () || child_file. is_valid_textfile) {
144+ if (child_file. is_valid_directory || child_file. is_valid_textfile) {
147145 _children. add (child_file);
148146 }
149147 }
@@ -200,10 +198,10 @@ namespace Scratch.FolderManager {
200198 }
201199
202200 public static int compare (File a , File b ) {
203- if (a. is_valid_directory () && b. is_valid_textfile) {
201+ if (a. is_valid_directory && b. is_valid_textfile) {
204202 return - 1 ;
205203 }
206- if (a. is_valid_textfile && b. is_valid_directory () ) {
204+ if (a. is_valid_textfile && b. is_valid_directory) {
207205 return 1 ;
208206 }
209207
0 commit comments