@@ -28,30 +28,45 @@ export default class Tools {
28
28
if ( remoteUrl ?. includes ( "github.com" ) ) {
29
29
const tooBigFiles = [ ] ;
30
30
31
+ const gitManager = this . plugin . gitManager ;
31
32
for ( const f of files ) {
32
33
const file = this . plugin . app . vault . getAbstractFileByPath (
33
34
f . vaultPath
34
35
) ;
36
+ let over100mb = false ;
37
+
35
38
if ( file instanceof TFile ) {
39
+ // Prefer the cached file size if available
36
40
if ( file . stat . size >= 100000000 ) {
37
- const gitManager = this . plugin . gitManager ;
38
- let isFileTrackedByLfs = false ;
39
- if ( gitManager instanceof SimpleGit ) {
40
- isFileTrackedByLfs =
41
- await gitManager . isFileTrackedByLFS ( f . path ) ;
42
- }
43
- if ( ! isFileTrackedByLfs ) {
44
- tooBigFiles . push ( f ) ;
45
- }
41
+ over100mb = true ;
42
+ }
43
+ } else {
44
+ const statRes = await this . plugin . app . vault . adapter . stat (
45
+ f . vaultPath
46
+ ) ;
47
+ if ( statRes && statRes . size >= 100000000 ) {
48
+ over100mb = true ;
49
+ }
50
+ }
51
+ if ( over100mb ) {
52
+ let isFileTrackedByLfs = false ;
53
+ if ( gitManager instanceof SimpleGit ) {
54
+ isFileTrackedByLfs =
55
+ await gitManager . isFileTrackedByLFS ( f . path ) ;
56
+ }
57
+ if ( ! isFileTrackedByLfs ) {
58
+ tooBigFiles . push ( f ) ;
46
59
}
47
60
}
48
61
}
49
62
50
63
if ( tooBigFiles . length > 0 ) {
51
64
this . plugin . displayError (
52
- `Did not commit, because following files are too big: ${ tooBigFiles
65
+ `Aborted commit, because the following files are too big:\n- ${ tooBigFiles
53
66
. map ( ( e ) => e . vaultPath )
54
- . join ( "\n" ) } . Please remove them.`
67
+ . join (
68
+ "\n- "
69
+ ) } \nPlease remove them or add to .gitignore.`
55
70
) ;
56
71
57
72
return true ;
0 commit comments